Last active
June 29, 2026 02:34
-
-
Save soda92/77b5070d1d282625c1733d89085f3043 to your computer and use it in GitHub Desktop.
Fix firebase-tools@15.22.3 error (#17030)
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 to Firebase Hosting on merge | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build_and_deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22' | |
| - name: Setup Hugo | |
| uses: peaceiris/actions-hugo@v3 | |
| with: | |
| hugo-version: 'latest' | |
| extended: true | |
| - name: Build Hugo Site | |
| run: | | |
| cd docs | |
| hugo | |
| - name: Deploy to Firebase Hosting Live | |
| env: | |
| SERVICE_ACCOUNT_JSON: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }} # replace with your secret name | |
| run: | | |
| # 1. Save service account key to a file | |
| echo "$SERVICE_ACCOUNT_JSON" > "$RUNNER_TEMP/firebase_service_account.json" | |
| export GOOGLE_APPLICATION_CREDENTIALS="$RUNNER_TEMP/firebase_service_account.json" | |
| # 2. Download the standalone Linux binary of firebase-tools | |
| echo "Downloading Firebase CLI standalone binary..." | |
| curl -sL https://github.com/firebase/firebase-tools/releases/latest/download/firebase-tools-linux -o "$RUNNER_TEMP/firebase" | |
| chmod +x "$RUNNER_TEMP/firebase" | |
| # 3. Run deploy and handle the redundant release 400 error | |
| set +e | |
| DEPLOY_OUTPUT=$("$RUNNER_TEMP/firebase" deploy --only hosting 2>&1) | |
| EXIT_CODE=$? | |
| set -e | |
| echo "$DEPLOY_OUTPUT" | |
| # Check if deploy succeeded or failed with "is the current active version" | |
| if [ $EXIT_CODE -ne 0 ] && echo "$DEPLOY_OUTPUT" | grep -q "is the current active version"; then | |
| echo "Deployment was already successful (redundant release error bypassed)." | |
| EXIT_CODE=0 | |
| fi | |
| if [ $EXIT_CODE -ne 0 ]; then | |
| echo "Deployment failed." | |
| exit $EXIT_CODE | |
| fi |
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 to Firebase Hosting on PR | |
| on: pull_request | |
| permissions: | |
| checks: write | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| build_and_preview: | |
| if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22' | |
| - name: Setup Hugo | |
| uses: peaceiris/actions-hugo@v3 | |
| with: | |
| hugo-version: 'latest' | |
| extended: true | |
| - name: Build Hugo Site | |
| run: | | |
| cd docs | |
| hugo | |
| - name: Deploy Preview to Firebase Hosting | |
| env: | |
| SERVICE_ACCOUNT_JSON: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }} # replace with your secret name | |
| run: | | |
| # 1. Save service account key to a file | |
| echo "$SERVICE_ACCOUNT_JSON" > "$RUNNER_TEMP/firebase_service_account.json" | |
| export GOOGLE_APPLICATION_CREDENTIALS="$RUNNER_TEMP/firebase_service_account.json" | |
| # 2. Define channel ID | |
| CHANNEL_ID="pr${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.ref }}" | |
| # 3. Download the standalone Linux binary of firebase-tools | |
| echo "Downloading Firebase CLI standalone binary..." | |
| curl -sL https://github.com/firebase/firebase-tools/releases/latest/download/firebase-tools-linux -o "$RUNNER_TEMP/firebase" | |
| chmod +x "$RUNNER_TEMP/firebase" | |
| # 4. Run deploy, capture output, and handle the redundant release 400 error | |
| set +e | |
| DEPLOY_OUTPUT=$("$RUNNER_TEMP/firebase" hosting:channel:deploy "$CHANNEL_ID" 2>&1) | |
| EXIT_CODE=$? | |
| set -e | |
| echo "$DEPLOY_OUTPUT" | |
| # Check if deploy succeeded or failed with "is the current active version" | |
| if [ $EXIT_CODE -ne 0 ] && echo "$DEPLOY_OUTPUT" | grep -q "is the current active version"; then | |
| echo "Deployment was already successful (redundant release error bypassed)." | |
| EXIT_CODE=0 | |
| fi | |
| if [ $EXIT_CODE -ne 0 ]; then | |
| echo "Deployment failed." | |
| exit $EXIT_CODE | |
| fi | |
| # 5. Extract the preview URL | |
| PREVIEW_URL=$(echo "$DEPLOY_OUTPUT" | grep -oE "https://[a-zA-Z0-9-]+--[a-zA-Z0-9.-]+\.(web\.app|firebaseapp\.com)" | head -n 1) | |
| if [ -z "$PREVIEW_URL" ]; then | |
| # Fallback: list channels to get the URL | |
| PREVIEW_URL=$("$RUNNER_TEMP/firebase" hosting:channel:list --json | jq -r ".result.channels[] | select(.name | split(\"/\") | last == \"$CHANNEL_ID\") | .url" | head -n 1) | |
| fi | |
| echo "Preview URL: $PREVIEW_URL" | |
| echo "PREVIEW_URL=$PREVIEW_URL" >> $GITHUB_ENV | |
| - name: Comment on PR with Preview URL | |
| if: env.PREVIEW_URL != '' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| COMMENT_BODY="🚀 Deploy Preview is ready! | |
| **Preview URL:** ${{ env.PREVIEW_URL }} | |
| *Last updated by commit ${{ github.event.pull_request.head.sha }}*" | |
| gh pr comment ${{ github.event.pull_request.number }} --body "$COMMENT_BODY" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
firebase/firebase-tools#10730