Deploy Python Firebase Functions #13
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 Python Firebase Functions | |
| on: | |
| push: | |
| branches: | |
| - add-deploy-workflow | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: 'Environment to deploy to' | |
| required: true | |
| default: 'staging' | |
| type: choice | |
| options: | |
| - staging | |
| - prod | |
| confirm_prod: | |
| description: 'Type "yes" to confirm production deployment' | |
| required: false | |
| type: string | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: deploy-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Validate production deployment | |
| if: ${{ github.event.inputs.environment == 'prod' }} | |
| run: | | |
| if [[ "${{ github.event.inputs.confirm_prod }}" != "yes" ]]; then | |
| echo "::error::Production deployment requires explicit confirmation. Please type 'yes' in the confirm_prod field." | |
| exit 1 | |
| fi | |
| - name: Prepare service account key | |
| id: prepare | |
| run: | | |
| if [[ "${{ github.event.inputs.environment }}" == "prod" ]]; then | |
| service_account_b64="${{ secrets.FIREBASE_PROD_SERVICE_ACCOUNT_B64 }}" | |
| else | |
| service_account_b64="${{ secrets.FIREBASE_STAGING_SERVICE_ACCOUNT_B64 }}" | |
| fi | |
| if [[ -z "$service_account_b64" ]]; then | |
| echo "::error::Missing service account secret" | |
| exit 1 | |
| fi | |
| if ! echo "$service_account_b64" | base64 --decode > /dev/null 2>&1; then | |
| echo "::error::Service account secret is not valid base64. Please ensure it is base64-encoded before storing as a secret." | |
| exit 1 | |
| fi | |
| echo "service_account_b64=$service_account_b64" >> $GITHUB_OUTPUT | |
| - name: Deploy Firebase Functions | |
| uses: ./ | |
| with: | |
| project_id: ${{ github.event.inputs.environment == 'prod' && 'hello-wisdom-prod' || 'hello-wisdom-staging' }} | |
| service_account_json_b64: ${{ steps.prepare.outputs.service_account_b64 }} |