Skip to content

Commit 18d14c9

Browse files
authored
fix: Optimize Firebase CI workflows with caching for firebase.json (#82)
- **Workflows Updated**: - **`delete-firebase-hosting-channel.yml`**: - Added caching for `firebase.json` using `actions/cache` to persist configuration across workflow runs. - Updated `actions/checkout` and `w9jds/firebase-action` to pinned versions for enhanced stability. - Conditional execution of Firebase actions based on cache availability. - **`firebase-hosting-pull-request.yml`**: - Implemented `actions/cache/save` to store `firebase.json` after build and test steps. - Updated workflow to ensure `firebase.json` is available for subsequent Firebase deployments. - **Impact**: - Speeds up Firebase workflow executions by reducing redundant `firebase.json` generation. - Enhances workflow reliability with pinned dependencies and optimized caching.
1 parent 2007e2a commit 18d14c9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.github/workflows/delete-firebase-hosting-channel.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@ jobs:
88
runs-on: ubuntu-24.04
99
timeout-minutes: 10
1010
steps:
11-
- uses: actions/checkout@v4
11+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
12+
- name: Restore firebase.json
13+
id: cache-restore-firebase-json
14+
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
15+
env:
16+
cache-name: firebase
17+
with:
18+
path: firebase.json
19+
key: ${{ github.head_ref }}
1220
- uses: w9jds/firebase-action@12e7dd1a31239567f9b4d398e6c1dc9f1c6fc70a # v13.28.0
21+
if: steps.cache-restore-firebase-json.outputs.cache-hit == 'true'
1322
with:
1423
# Extracts the full channel name from the PR number and feeds it to the delete command
1524
args: hosting:channel:list | grep 'pr${{ github.event.pull_request.number }}' | cut --delimiter ' ' --fields 2 | xargs -I {} firebase hosting:channel:delete --force {}

.github/workflows/firebase-hosting-pull-request.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ jobs:
2323
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
2424
- name: Build and Test
2525
run: ./scripts/build.sh
26+
- name: Save firebase.json
27+
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
28+
env:
29+
cache-name: firebase
30+
with:
31+
path: firebase.json
32+
key: ${{ github.head_ref }}
2633
- uses: FirebaseExtended/action-hosting-deploy@0cbcac4740c2bfb00d632f0b863b57713124eb5a # v0.9.0
2734
with:
2835
repoToken: '${{ secrets.GITHUB_TOKEN }}'

0 commit comments

Comments
 (0)