deploy-test #1273
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: deploy-test | |
on: | |
workflow_run: | |
workflows: [server-build, ci-web, web-build, worker-build] | |
types: [completed] | |
branches: [main] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }}-${{github.event.workflow_run.name}} | |
cancel-in-progress: true | |
env: | |
GCP_REGION: us-central1 | |
# TODO: Remove after dockerizing the web. | |
GCS_DEST: gs://cms.test.reearth.dev | |
# server | |
SERVER_IMAGE: reearth/reearth-cms:nightly | |
SERVER_IMAGE_NAME: us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/reearth/reearth-cms:nightly | |
SERVER_IMAGE_GCP: us-central1-docker.pkg.dev/reearth-oss/reearth/reearth-cms:nightly | |
# web | |
WEB_IMAGE: reearth/reearth-cms-web:nightly | |
WEB_IMAGE_NAME: us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/reearth/reearth-cms-web:nightly | |
WEB_IMAGE_GCP: us-central1-docker.pkg.dev/reearth-oss/reearth/reearth-cms-web:nightly | |
# worker | |
WORKER_IMAGE: reearth/reearth-cms-worker:nightly | |
WORKER_IMAGE_NAME: us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/reearth/reearth-cms-worker:nightly | |
WORKER_IMAGE_GCP: us-central1-docker.pkg.dev/reearth-oss/reearth/reearth-cms-worker:nightly | |
jobs: | |
# TODO: Remove after dockerizing the web. | |
deploy_web_gcs: | |
name: Deploy web to test env | |
if: github.event.repository.full_name == 'reearth/reearth-cms' && github.event.workflow_run.name == 'ci-web' && github.event.workflow_run.conclusion != 'failure' && github.event.workflow_run.head_branch == 'main' | |
runs-on: ubuntu-latest | |
steps: | |
- 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: get latest web artifact | |
uses: dawidd6/action-download-artifact@v3.1.4 | |
with: | |
github_token: ${{ steps.app-token.outputs.token }} | |
workflow: ci_web.yml | |
workflow_conclusion: success | |
branch: main | |
name: reearth-cms-web | |
check_artifacts: true | |
search_artifacts: true | |
- name: Extract | |
run: tar -xvf reearth-cms-web.tar.gz | |
- uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: "${{ secrets.GCP_SA_KEY }}" | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v2 | |
- name: Deploy | |
run: gsutil -m -h "Cache-Control:no-store" rsync -x "^reearth_config\\.json$" -dr reearth-cms-web/ $GCS_DEST | |
deploy_server: | |
name: Deploy server to test env | |
runs-on: ubuntu-latest | |
if: github.event.repository.full_name == 'reearth/reearth-cms' && github.event.workflow_run.name == 'server-build' && github.event.workflow_run.conclusion != 'failure' && github.event.workflow_run.head_branch == 'main' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.GCP_SA_KEY }} | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v2 | |
- name: Configure docker | |
run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet | |
- name: docker push | |
run: | | |
docker pull $SERVER_IMAGE | |
docker tag $SERVER_IMAGE $SERVER_IMAGE_GCP | |
docker push $SERVER_IMAGE_GCP | |
- name: Deploy to Cloud Run | |
run: | | |
gcloud run deploy reearth-cms-backend \ | |
--image $SERVER_IMAGE_GCP \ | |
--region $GCP_REGION \ | |
--platform managed \ | |
--quiet | |
deploy_web: | |
name: Deploy web to test env | |
runs-on: ubuntu-latest | |
if: github.event.repository.full_name == 'reearth/reearth-cms' && github.event.workflow_run.name == 'web-build' && github.event.workflow_run.conclusion != 'failure' && github.event.workflow_run.head_branch == 'main' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.GCP_SA_KEY }} | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v2 | |
- name: Configure docker | |
run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet | |
- name: docker push | |
run: | | |
docker pull $WEB_IMAGE | |
docker tag $WEB_IMAGE $WEB_IMAGE_GCP | |
docker push $WEB_IMAGE_GCP | |
- name: Deploy to Cloud Run | |
run: | | |
gcloud run deploy reearth-cms-web \ | |
--image $WEB_IMAGE_GCP \ | |
--region $GCP_REGION \ | |
--platform managed \ | |
--quiet | |
deploy_worker: | |
name: Deploy worker to test env | |
runs-on: ubuntu-latest | |
if: github.event.repository.full_name == 'reearth/reearth-cms' && github.event.workflow_run.name == 'worker-build' && github.event.workflow_run.conclusion != 'failure' && github.event.workflow_run.head_branch == 'main' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.GCP_SA_KEY }} | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v2 | |
- name: Configure docker | |
run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet | |
- name: docker push | |
run: | | |
docker pull $WORKER_IMAGE | |
docker tag $WORKER_IMAGE $WORKER_IMAGE_GCP | |
docker push $WORKER_IMAGE_GCP | |
- name: Deploy to Cloud Run | |
run: | | |
gcloud run deploy reearth-cms-worker \ | |
--image $WORKER_IMAGE_GCP \ | |
--region $GCP_REGION \ | |
--platform managed \ | |
--quiet |