Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

⭐️ Deploy reearth dev #133

⭐️ Deploy reearth dev

⭐️ Deploy reearth dev #133

name: ⭐️ Deploy reearth dev
on:
workflow_dispatch:
env:
GCS_DEST: gs://plateau-dev-reearth-app-bucket
# TODO: allow to specify version of reearth
IMAGE_NAME: reearth/reearth:rc
IMAGE_NAME_GHCR: ghcr.io/eukarya-inc/reearth-plateauview/reearth:latest
IMAGE_NAME_GCP: asia.gcr.io/reearth-plateau-dev/reearth:latest
GCP_WORKLOAD_IDENTITY_PROVIDER: projects/383489516390/locations/global/workloadIdentityPools/github-actions-oidc/providers/github-provider
GCP_SERVICE_ACCOUNT: github-cicd-oidc@reearth-plateau-dev.iam.gserviceaccount.com
GCP_REGION: asia-northeast1
concurrency:
group: ${{ github.workflow }}
jobs:
deploy_web:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.GCP_SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Download reearth-web
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: reearth/reearth
version: tags/rc
file: reearth-web_rc.tar.gz
token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract
run: mv reearth-web{_rc,}.tar.gz && tar -xvf reearth-web.tar.gz
- name: Replace favicon / App name
env:
PLATEAU_FAVICON: https://www.mlit.go.jp/plateau/assets/img/icons/favicon.svg
APP_PATH: reearth-web/index.html
PUBLISH_PATH: reearth-web/published.html
APP_NAME: PLATEAU VIEW(Ver2.0)
run: |
APP_SOURCE=$(cat $APP_PATH)
APP_SOURCE=${APP_SOURCE/\/static\/favicon*.ico/$PLATEAU_FAVICON}
APP_SOURCE=${APP_SOURCE/\<title\>*\<\/title\>/<title>$APP_NAME</title>}
PUBLISH_SOURCE=$(cat $PUBLISH_PATH)
PUBLISH_SOURCE=${PUBLISH_SOURCE/\/static\/favicon*.ico/$PLATEAU_FAVICON}
PUBLISH_SOURCE=${PUBLISH_SOURCE/\<title\>*\<\/title\>/<title>$APP_NAME</title>}
echo $APP_SOURCE > $APP_PATH
echo $PUBLISH_SOURCE > $PUBLISH_PATH
- name: Deploy
run: gsutil -m -h "Cache-Control:no-store" rsync -x "^cloud/.*$|^reearth_config\\.json$|^extension/.*$" -dr reearth-web/ ${{ env.GCS_DEST }}
- name: Pack web
run: |
rm reearth-web.tar.gz
tar -zcvf reearth-web.tar.gz reearth-web
- name: Save as artifact
uses: actions/upload-artifact@v2
with:
name: reearth-web
path: reearth-web.tar.gz
deploy_server:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.GCP_SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure docker
run: gcloud auth configure-docker --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 $IMAGE_NAME
- name: Tag docker images
run: docker tag $IMAGE_NAME $IMAGE_NAME_GHCR && docker tag $IMAGE_NAME $IMAGE_NAME_GCP
- name: Push docker images
run: docker push $IMAGE_NAME_GHCR && docker push $IMAGE_NAME_GCP
- name: Deploy
run: |
gcloud run deploy reearth-api \
--image $IMAGE_NAME_GCP \
--region $GCP_REGION \
--platform managed \
--quiet