I’m facing an issue with my GitHub Actions CI/CD setup for deploying a web app to Firebase Hosting. I’ve set up three workflows:
Pull Request Workflow: Validates code on PR creation. Build Workflow: Generates the build artifact (uploads build folder). Deploy Workflow: Deploys to Firebase Hosting, triggered via workflow_run after a successful build.
The workflows run in order, and the run-id matches between Build and Deploy (e.g., 1632955673). The Build workflow successfully uploads the build artifact, but the Deploy workflow fails with "Unable to download artifact(s): Artifact not found for name: build" and logs show "artifacts": []. This breaks the deployment.
What We’ve Tried:
- Confirmed run-id consistency via debug logs.
- Added retention-days: 7 to Upload Build Artifact.
- Updated Download Build Artifact with run-id: ${{ github.event.workflow_run.id }} to target the Build run.
- Enhanced debugging with ls -la to verify the build folder post-upload.
name: Firebase Deployment Build
on:
push:
branches:
- master
jobs:
build:
name: Generate Build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Dependencies
run: npm install --legacy-peer-deps
- name: Build
env:
CI: false
run: npm run build
- name: Verify Build Directory
run: ls -la || echo "Build directory not found"
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: build
path: build
- name: Confirm Artifact Upload
run: echo "Artifact upload completed"
- name: Log Build Run ID
run: echo "Build Run ID - ${{ github.run_id }}"
name: Deploy to Firebase Hosting on successful build
'on':
workflow_run:
workflows: [Firebase Deployment Build]
types:
- completed
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Debug Workflow Context
run: |
echo "Triggering Workflow Run ID: ${{ github.event.workflow_run.id }}"
echo "Triggering Workflow Name: ${{ github.event.workflow_run.name }}"
echo "Triggering Workflow Conclusion: ${{ github.event.workflow_run.conclusion }}"
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: build
path: build
- name: Verify Downloaded Artifact
run: ls -la build || echo "Build artifact not found after download"
- name: Debug Deployment Directory
run: |
echo "Current directory contents:"
ls -la
echo "Build directory contents:"
ls -la build || echo "Build directory not found"
- name: Deploy to Firebase
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
channelId: live
projectId: tabrez-portfolio-2
I’ve some CI/CD knowledge, managing this pipeline myself. I spent late night refactoring deprecated Firebase Hosting methods (e.g., switching from tokens to service accounts), and this last hurdle is keeping me from peace. I’d love input from DevOps experts or those who’ve tackled similar Firebase deployment issues.
Question: Why is the artifact array empty despite a successful upload? Any misconfigurations or alternative approaches to ensure artifact availability across workflows?
${{ github.run_id }}actually the same if you print${{ github.run_id }}in the second workflow? If not, you'd probably want to add${{ github.event.workflow_run.id }}as the run ID foractions/download-artifact.permissions: actions: read contents: readEarlier, I had combined the Build and Deploy into a single workflow, which was working smoothly but I wanted to keep separate workflows.