fix: workflow #19
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 to cloud run | |
on: | |
push: | |
branches: [main] | |
paths: | |
- 'service/common-job/**' | |
workflow_dispatch: | |
env: | |
REGION: asia-northeast1 | |
ARTIFACT_REPOSITORY: asia-northeast1-docker.pkg.dev | |
IMAGE_NAME: vspo-portal-cron | |
DOCKERFILE: Dockerfile | |
jobs: | |
blue: | |
name: deploy to Cloud Run to develop environment | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./service/common-job | |
env: | |
JOB_NAME: blue-vspo-portal | |
REPOSITORY_NAME: blue-vspo-portal | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- uses: actions/checkout@v4 | |
- id: 'auth' | |
uses: 'google-github-actions/auth@v2' | |
with: | |
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} | |
service_account: ${{ secrets.SERVICE_ACCOUNT }} | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v2' | |
with: | |
version: '>= 363.0.0' | |
- name: Authorize Docker | |
run: gcloud auth configure-docker $ARTIFACT_REPOSITORY --quiet | |
- name: Build and push Docker image to Artifact Registry for cron | |
run: | | |
IMAGE_TAG=$(git rev-parse --short "$GITHUB_SHA") | |
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV | |
docker build --target http-serve -t $ARTIFACT_REPOSITORY/$GCP_PROJECT/$REPOSITORY_NAME/$IMAGE_NAME:$IMAGE_TAG -f $DOCKERFILE . | |
docker tag $ARTIFACT_REPOSITORY/$GCP_PROJECT/$REPOSITORY_NAME/$IMAGE_NAME:$IMAGE_TAG $ARTIFACT_REPOSITORY/$GCP_PROJECT/$REPOSITORY_NAME/$IMAGE_NAME:latest | |
docker push $ARTIFACT_REPOSITORY/$GCP_PROJECT/$REPOSITORY_NAME/$IMAGE_NAME:$IMAGE_TAG && docker push $ARTIFACT_REPOSITORY/$GCP_PROJECT/$REPOSITORY_NAME/$IMAGE_NAME:latest | |
- id: deploy | |
uses: google-github-actions/deploy-cloudrun@v2 | |
with: | |
service: 'blue-vspo-portal' | |
image: ${{ env.ARTIFACT_REPOSITORY }}/${{ env.GCP_PROJECT }}/${{ env.REPOSITORY_NAME }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
region: ${{ env.REGION }} | |
no_traffic: false |