Skip to content

⭐️ Deploy CMS dev #10

⭐️ Deploy CMS dev

⭐️ Deploy CMS dev #10

name: ⭐️ Deploy CMS dev
on:
workflow_dispatch:
env:
GCS_DEST: gs://cms-plateau-dev
CMS_IMAGE_NAME: reearth/reearth-cms:rc
CMS_IMAGE_NAME_GHCR: ghcr.io/eukarya-inc/plateau-view-3.0/reearth-cms:latest
CMS_IMAGE_NAME_GCP: asia-northeast1-docker.pkg.dev/reearth-plateau-dev/reearth-plateau/reearth-cms:latest
CMS_WEB_IMAGE_NAME: reearth/reearth-cms-web:rc
CMS_WEB_IMAGE_NAME_GHCR: ghcr.io/eukarya-inc/plateau-view-3.0/reearth-cms-web:latest
CMS_WEB_IMAGE_NAME_GCP: asia-northeast1-docker.pkg.dev/reearth-plateau-dev/reearth-plateau/reearth-cms-web:latest
CMS_WORKER_IMAGE_NAME: reearth/reearth-cms-worker:rc
CMS_WORKER_IMAGE_NAME_GHCR: ghcr.io/eukarya-inc/plateau-view-3.0/reearth-cms-worker:latest
CMS_WORKER_IMAGE_NAME_GCP: asia-northeast1-docker.pkg.dev/reearth-plateau-dev/reearth-plateau/reearth-cms-worker:latest
concurrency:
group: ${{ github.workflow }}
jobs:
deploy_web:
runs-on: ubuntu-latest
environment: dev
permissions:
contents: read
id-token: write
packages: write
if: github.event.repository.full_name == 'eukarya-inc/PLATEAU-VIEW-3.0'
steps:
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure docker
run: gcloud auth configure-docker asia-northeast1-docker.pkg.dev --quiet
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull docker images
run: docker pull $CMS_WEB_IMAGE_NAME
- name: Tag docker images
run: |
docker tag $CMS_WEB_IMAGE_NAME $CMS_WEB_IMAGE_NAME_GHCR
docker tag $CMS_WEB_IMAGE_NAME $CMS_WEB_IMAGE_NAME_GCP
- name: Push docker images
run: |
docker push $CMS_WEB_IMAGE_NAME_GHCR
docker push $CMS_WEB_IMAGE_NAME_GCP
- name: Deploy
run: |
gcloud run deploy reearth-cms-web \
--image $CMS_WEB_IMAGE_NAME_GCP \
--region $GCP_REGION \
--platform managed \
--quiet
env:
GCP_REGION: ${{ vars.GCP_REGION }}
# TODO: Remove after migrating to Cloud Run.
deploy_web_gcs:
runs-on: ubuntu-latest
if: github.event.repository.full_name == 'eukarya-inc/PLATEAU-VIEW-3.0'
environment: dev
permissions:
contents: read
id-token: write
packages: write
steps:
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Download CMS web
uses: dawidd6/action-download-artifact@v6
with:
github_token: ${{ steps.app-token.outputs.token }}
repo: reearth/reearth-cms
workflow: ci_web.yml
branch: release
name: reearth-cms-web
check_artifacts: true
search_artifacts: true
- name: Extract
run: tar -xvf reearth-cms-web.tar.gz
- name: Replace favicon / App name
env:
PLATEAU_FAVICON: https://cms.plateau.reearth.io/img/favicon.ico
APP_PATH: reearth-cms-web/index.html
APP_NAME: PLATEAU CMS
run: |
SOURCE=$(cat $APP_PATH)
SOURCE=${SOURCE/\/assets\/favicon*.ico/$PLATEAU_FAVICON}
SOURCE=${SOURCE/\<title\>*\<\/title\>/<title>$APP_NAME</title>}
echo $SOURCE > $APP_PATH
- name: Deploy
run: gsutil -m -h "Cache-Control:no-store" rsync -x "^reearth_config\\.json$" -dr reearth-cms-web/ ${{ env.GCS_DEST }}
- name: Pack web
run: |
rm reearth-cms-web.tar.gz
tar -zcvf reearth-cms-web.tar.gz reearth-cms-web
- name: Save as artifact
uses: actions/upload-artifact@v4
with:
name: reearth-cms-web
path: reearth-cms-web.tar.gz
deploy_server_worker:
runs-on: ubuntu-latest
environment: dev
permissions:
contents: read
id-token: write
packages: write
if: github.event.repository.full_name == 'eukarya-inc/PLATEAU-VIEW-3.0'
steps:
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure docker
run: gcloud auth configure-docker asia-northeast1-docker.pkg.dev --quiet
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull docker images
run: docker pull $CMS_IMAGE_NAME && docker pull $CMS_WORKER_IMAGE_NAME
- name: Tag docker images
run: |
docker tag $CMS_IMAGE_NAME $CMS_IMAGE_NAME_GHCR && \
docker tag $CMS_IMAGE_NAME $CMS_IMAGE_NAME_GCP && \
docker tag $CMS_WORKER_IMAGE_NAME $CMS_WORKER_IMAGE_NAME_GHCR && \
docker tag $CMS_WORKER_IMAGE_NAME $CMS_WORKER_IMAGE_NAME_GCP
- name: Push docker images
run: |
docker push $CMS_IMAGE_NAME_GHCR && \
docker push $CMS_IMAGE_NAME_GCP && \
docker push $CMS_WORKER_IMAGE_NAME_GHCR && \
docker push $CMS_WORKER_IMAGE_NAME_GCP
- name: Deploy
run: |
gcloud run deploy reearth-cms-api \
--image $CMS_IMAGE_NAME_GCP \
--region $GCP_REGION \
--platform managed \
--quiet
gcloud run deploy reearth-cms-worker \
--image $CMS_WORKER_IMAGE_NAME_GCP \
--region $GCP_REGION \
--platform managed \
--quiet
env:
GCP_REGION: ${{ vars.GCP_REGION }}