|
| 1 | +name: fireway migrate |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + workload-identity-project-number: |
| 7 | + description: the GCP project number used for Workload Identity Federation |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + gcp-project-id: |
| 11 | + description: The firebase project environment used for the deployment |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + gcp-service-account: |
| 15 | + description: the email address of the service account |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + working-directory: |
| 19 | + description: The working directory of the firebase project |
| 20 | + required: false |
| 21 | + type: string |
| 22 | + default: functions |
| 23 | + dry-run: |
| 24 | + description: run migrations in dry-run mode |
| 25 | + type: boolean |
| 26 | + required: false |
| 27 | + default: false |
| 28 | + slack-channel-id: |
| 29 | + description: Slack channel id to send alerts to |
| 30 | + type: string |
| 31 | + required: false |
| 32 | + |
| 33 | +jobs: |
| 34 | + fireway: |
| 35 | + name: fireway |
| 36 | + runs-on: ubuntu-latest |
| 37 | + permissions: |
| 38 | + contents: read |
| 39 | + id-token: write |
| 40 | + concurrency: |
| 41 | + group: fireway-migrate-${{ inputs.gcp-project-id }} |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v6 |
| 44 | + - name: setup pnpm |
| 45 | + uses: valian-ca/github-workflows/.github/actions/setup-pnpm@main |
| 46 | + - uses: valian-ca/github-workflows/.github/actions/gcp-github-auth@main |
| 47 | + with: |
| 48 | + workload-identity-project-number: ${{ inputs.workload-identity-project-number }} |
| 49 | + gcp-service-account: ${{ inputs.gcp-service-account }} |
| 50 | + |
| 51 | + - uses: google-github-actions/setup-gcloud@v3 |
| 52 | + with: |
| 53 | + project_id: ${{ inputs.gcp-project-id }} |
| 54 | + |
| 55 | + - name: configure firebase environment |
| 56 | + run: npx firebase use ${{ inputs.gcp-project-id }} |
| 57 | + working-directory: ${{ inputs.working-directory }} |
| 58 | + |
| 59 | + - name: run migrations ${{ inputs.dry-run && 'in dry run mode' || '' }} |
| 60 | + env: |
| 61 | + GCLOUD_PROJECT: ${{ inputs.gcp-project-id }} |
| 62 | + run: npx @valian/fireway migrate ${{ inputs.dry-run && '--dryRun' || '' }} |
| 63 | + working-directory: ${{ inputs.working-directory }} |
| 64 | + |
| 65 | + - name: notify Slack of failure |
| 66 | + id: slack |
| 67 | + if: ${{ !success() && inputs.slack-channel-id != '' }} |
| 68 | + uses: valian-ca/github-workflows/.github/actions/slack-alert@main |
| 69 | + with: |
| 70 | + message: fireway migrate ${{ inputs.gcp-project-id }} error |
| 71 | + mrkdwn: | |
| 72 | + :warning: fireway migrate *${{ inputs.gcp-project-id }}* (`${{ job.status }}`) |
| 73 | + token: ${{ secrets.SLACK_BOT_TOKEN }} |
| 74 | + channel: ${{ inputs.slack-channel-id }} |
0 commit comments