Update OpenAPI schema (#16) #58
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: CD | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| environment_name: | |
| description: Environment | |
| required: true | |
| type: choice | |
| options: | |
| - dev | |
| - stg | |
| - qa | |
| - prod | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ 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: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set Environmet | |
| id: set-env | |
| run: | | |
| # Environment | |
| IS_WORKFLOW_DISPATCH="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment_name != '' }}" | |
| IS_PUSH_TO_MAIN="${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.base_ref == 'main') }}" | |
| if [ $IS_WORKFLOW_DISPATCH = "true" ]; then | |
| export TARGET_ENVIRONMENT="${{ github.event.inputs.environment_name }}" | |
| elif [ $IS_PUSH_TO_MAIN = "true" ]; then | |
| export TARGET_ENVIRONMENT="stg" | |
| else | |
| exit 1 | |
| fi | |
| echo "Environment: $TARGET_ENVIRONMENT" | |
| # Service name suffix | |
| if [ "$TARGET_ENVIRONMENT" = "prod" ]; then | |
| export SERVICE_NAME_SUFFIX="" | |
| else | |
| export SERVICE_NAME_SUFFIX="-$TARGET_ENVIRONMENT" | |
| fi | |
| export REPO_NAME=$(echo ${{ github.repository }} | awk -F '/' '{print $2}') | |
| export SERVICE_NAME=$REPO_NAME$SERVICE_NAME_SUFFIX | |
| export IMAGE_TAG=${{ vars._AR_HOSTNAME }}/${{ vars.PROJECT_ID }}/github-actions/$REPO_NAME/$SERVICE_NAME:${{ github.sha }} | |
| echo "Repository name: $REPO_NAME" | |
| echo "Service name: $SERVICE_NAME" | |
| echo "Image tag: $IMAGE_TAG" | |
| echo "environment=$TARGET_ENVIRONMENT" >> "$GITHUB_OUTPUT" | |
| echo "service_name=$SERVICE_NAME" >> "$GITHUB_OUTPUT" | |
| echo "image_tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT" | |
| 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: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Build | |
| run: | | |
| docker build \ | |
| -t ${{ env.IMAGE_TAG }} \ | |
| . \ | |
| -f Dockerfile \ | |
| --no-cache \ | |
| --build-arg NEXT_PUBLIC_FIREBASE_API_KEY=${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }} \ | |
| --build-arg NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }} \ | |
| --build-arg NEXT_PUBLIC_FIREBASE_PROJECT_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }} \ | |
| --build-arg NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }} \ | |
| --build-arg NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }} \ | |
| --build-arg NEXT_PUBLIC_FIREBASE_APP_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }} \ | |
| --build-arg NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }} | |
| - name: Authenticate | |
| id: auth | |
| uses: google-github-actions/auth@v3 | |
| with: | |
| workload_identity_provider: ${{ vars.WORKLOAD_IDENTITY_PROVIDER }} | |
| service_account: ${{ vars.SERVICE_ACCOUNT }} | |
| - name: Setup Google Cloud | |
| 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: | |
| - name: Authenticate | |
| id: auth | |
| uses: google-github-actions/auth@v3 | |
| with: | |
| workload_identity_provider: ${{ vars.WORKLOAD_IDENTITY_PROVIDER }} | |
| service_account: ${{ vars.SERVICE_ACCOUNT }} | |
| - name: Deploy | |
| id: deploy | |
| uses: google-github-actions/deploy-cloudrun@v3 | |
| with: | |
| service: ${{ env.SERVICE_NAME }} | |
| image: ${{ env.IMAGE_TAG }} | |
| region: ${{ vars._DEPLOY_REGION }} | |
| env_vars: | | |
| NEXT_PUBLIC_FIREBASE_API_KEY=${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }} | |
| NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }} | |
| NEXT_PUBLIC_FIREBASE_PROJECT_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }} | |
| NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }} | |
| NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }} | |
| NEXT_PUBLIC_FIREBASE_APP_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }} | |
| NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }} | |
| NEXT_PUBLIC_API_BASE_URL=${{ vars.NEXT_PUBLIC_API_BASE_URL }} | |
| env_vars_update_strategy: overwrite |