Deploy #11
This file contains hidden or 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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| environment_name: | |
| description: Environment | |
| required: true | |
| type: choice | |
| options: | |
| - dev | |
| - stg | |
| - qa | |
| - prod | |
| concurrency: | |
| group: ${{ github.repository }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.event.inputs.environment_name }} | |
| cancel-in-progress: true | |
| jobs: | |
| set-env: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| environment: ${{ steps.set-env.outputs.environment }} | |
| service_name: ${{ steps.set-env.outputs.service_name }} | |
| image_tag: ${{ steps.set-env.outputs.image_tag }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - id: set-env | |
| uses: fun-dotto/way/.github/actions/set-env@main | |
| with: | |
| ar_hostname: ${{ vars._AR_HOSTNAME }} | |
| project_id: ${{ vars.PROJECT_ID }} | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| env: | |
| SERVICE_NAME: ${{ needs.set-env.outputs.service_name }} | |
| IMAGE_TAG: ${{ needs.set-env.outputs.image_tag }} | |
| needs: | |
| - set-env | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| submodules: true | |
| - name: Build | |
| run: | | |
| docker build \ | |
| -t ${{ env.IMAGE_TAG }} \ | |
| . \ | |
| -f Dockerfile \ | |
| --no-cache | |
| - uses: google-github-actions/auth@v3 | |
| with: | |
| workload_identity_provider: ${{ vars.WORKLOAD_IDENTITY_PROVIDER }} | |
| service_account: ${{ vars.SERVICE_ACCOUNT }} | |
| - uses: google-github-actions/setup-gcloud@v3 | |
| with: | |
| project_id: ${{ vars.PROJECT_ID }} | |
| - name: Configure Docker | |
| run: | | |
| gcloud auth \ | |
| configure-docker \ | |
| ${{ vars._AR_HOSTNAME }} | |
| - name: Push | |
| run: | | |
| docker push \ | |
| ${{ env.IMAGE_TAG }} | |
| deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| environment: ${{ needs.set-env.outputs.environment }} | |
| env: | |
| SERVICE_NAME: ${{ needs.set-env.outputs.service_name }} | |
| IMAGE_TAG: ${{ needs.set-env.outputs.image_tag }} | |
| needs: | |
| - set-env | |
| - build-and-push | |
| steps: | |
| - uses: google-github-actions/auth@v3 | |
| with: | |
| workload_identity_provider: ${{ vars.WORKLOAD_IDENTITY_PROVIDER }} | |
| service_account: ${{ vars.SERVICE_ACCOUNT }} | |
| - uses: google-github-actions/deploy-cloudrun@v3 | |
| with: | |
| service: ${{ env.SERVICE_NAME }} | |
| image: ${{ env.IMAGE_TAG }} | |
| region: ${{ vars._DEPLOY_REGION }} | |
| env_vars: | | |
| ACADEMIC_API_URL=${{ vars.ACADEMIC_API_URL }} | |
| ANNOUNCEMENT_API_URL=${{ vars.ANNOUNCEMENT_API_URL }} | |
| FUNCH_API_URL=${{ vars.FUNCH_API_URL }} | |
| USER_API_URL=${{ vars.USER_API_URL }} | |
| env_vars_update_strategy: overwrite | |
| secrets_update_strategy: overwrite |