Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion .github/workflows/deploy-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ jobs:
"$IMAGE_BASE:${{ env.IMAGE_TAG_BASE }}-arm64"
docker manifest push "$IMAGE_BASE:${{ env.IMAGE_TAG_BASE }}"

deploy:
deploy-aws:
if: ${{ github.repository == 'web3infra-foundation/mega' }}
needs: manifest
runs-on: ubuntu-latest
strategy:
Expand All @@ -133,3 +134,33 @@ jobs:
AWS_REGION: ap-southeast-2
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

deploy-gcp:
needs: manifest
if: ${{ github.repository == 'web3infra-foundation/mega' }}
runs-on: ubuntu-latest
steps:
- name: Auth to GCP
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}

- name: Deploy to Cloud Run (force new revision)
env:
REGION: asia-east1
SERVICE_NAME: buck2-hub-campsite
run: |
set -euo pipefail

IMAGE=$(gcloud run services describe $SERVICE_NAME \
--project "$GCP_PROJECT_ID" \
--region "$REGION" \
--format="value(spec.template.spec.containers[0].image)")

echo "Current image: $IMAGE"

gcloud run deploy $SERVICE_NAME \
--image "$IMAGE" \
--region "$REGION" \
--project "$GCP_PROJECT_ID" \
--quiet
4 changes: 2 additions & 2 deletions api/app/views/users/sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% @page_title = "Sign in - Campsite" %>
<% @page_title = "Sign in - #{Rails.configuration.x.app_name}" %>

<main class="outer-container">
<div class="inner-container">
Expand All @@ -11,7 +11,7 @@
<h2 class="page-title">Sign in</h2>

<span class="w-full text-sm text-tertiary">
Login to Mega with Github Now
Login to <%= Rails.configuration.x.app_name %> with Github Now
</span>
</div>

Expand Down
32 changes: 16 additions & 16 deletions api/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,23 @@ staging-gitmono:
ssl_mode: required
replica: true

staging-buck2hub:
primary:
<<: *default
username: <%= Rails.application.credentials.dig(:mysql, :username) %>
password: <%= Rails.application.credentials.dig(:mysql, :password) %>
database: campsite_api_buck2hub
host: <%= Rails.application.credentials.dig(:mysql, :host) %>
ssl_mode: required
staging-buck2hub:
primary:
<<: *default
username: <%= Rails.application.credentials.dig(:mysql, :username) %>
password: <%= Rails.application.credentials.dig(:mysql, :password) %>
database: campsite_api_buck2hub
host: <%= Rails.application.credentials.dig(:mysql, :host) %>
ssl_mode: required

primary_replica:
<<: *default
username: <%= Rails.application.credentials.dig(:mysql, :username) %>
password: <%= Rails.application.credentials.dig(:mysql, :password) %>
database: campsite_api_buck2hub
host: <%= Rails.application.credentials.dig(:mysql, :host) %>
ssl_mode: required
replica: true
primary_replica:
<<: *default
username: <%= Rails.application.credentials.dig(:mysql, :username) %>
password: <%= Rails.application.credentials.dig(:mysql, :password) %>
database: campsite_api_buck2hub
host: <%= Rails.application.credentials.dig(:mysql, :host) %>
ssl_mode: required
replica: true

demo:
primary:
Expand Down
1 change: 1 addition & 0 deletions api/config/environments/demo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,5 @@
config.hosts << "gitmono.local"
config.hosts << "localhost"
config.hosts << "127.0.0.1"
config.x.app_name = "Mega Local Demo"
end
6 changes: 6 additions & 0 deletions api/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

# config.action_dispatch.tld_length = 2

# Do not eager load code on boot.
config.eager_load = false

Expand Down Expand Up @@ -84,4 +86,8 @@
config.hosts << "auth.gitmono.test"
config.hosts << "api.gitmono.test"
config.hosts << "gitmono.test"
config.hosts << "auth.xuanwu.openatom.cn:3001"
# config.hosts << "auth.gitmono.local:3001"

config.x.app_name = "Mega Dev"
end
1 change: 1 addition & 0 deletions api/config/environments/staging-buck2hub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,5 @@
/172\.31\.\d+\.\d+/,
/192\.168\.\d+\.\d+/,
]
config.x.app_name = "Buck2Hub"
end
1 change: 1 addition & 0 deletions api/config/environments/staging-gitmono.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,5 @@
/172\.31\.\d+\.\d+/,
/192\.168\.\d+\.\d+/,
]
config.x.app_name = "Mega App"
end
12 changes: 1 addition & 11 deletions api/config/environments/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
config.hosts << "api.gitmega.com"
config.hosts << "gitmega.com"


# config.hosts << "mega-campsite-api.fly.dev"

# 允许 AWS VPC 中常见的私有 IP 网段访问
Expand All @@ -120,14 +119,5 @@
# required to access the app via Fly private network
# config.hosts << "mega-campsite-api.internal"

# Rails.application.config.middleware.insert_before 0, Rack::Cors do
# allow do
# origins 'http://admin.gitmega.com', 'http://auth.gitmega.com', 'http://api.gitmega.com', 'http://home.gitmega.com'

# resource '*',
# headers: :any,
# methods: [:get, :post, :put, :patch, :delete, :options, :head],
# credentials: true
# end
# end
config.x.app_name = "Mega App"
end