Skip to content

Commit c6df1ef

Browse files
Setup Targeted Dependency Update GitHub Action (#1266)
* chore: Setup GitHub Action for targeted dependency update This action updates firebase-functions and firebase-admin across Node.js and Python samples using pnpm and a custom python bash script. Co-authored-by: jhuleatt <3759507+jhuleatt@users.noreply.github.com> * chore: Setup GitHub Action for targeted dependency update This action updates firebase-functions and firebase-admin across Node.js and Python samples using pnpm and a custom python bash script. Addresses PR comments by using the built-in gh cli for creating pull requests. Co-authored-by: jhuleatt <3759507+jhuleatt@users.noreply.github.com> --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent fc6be76 commit c6df1ef

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Targeted Dependency Update
2+
on:
3+
schedule:
4+
- cron: '0 0 * * 1' # Weekly
5+
workflow_dispatch: # Manual trigger
6+
7+
jobs:
8+
targeted-update:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
# --- NODE SECTION (Using pnpm) ---
17+
- uses: pnpm/action-setup@v3
18+
with:
19+
version: 9
20+
- name: Update specific Node packages
21+
run: |
22+
# Use the -r (recursive) flag to find all package.json files
23+
# and update ONLY the listed packages to the latest version
24+
pnpm up -L -r firebase-functions firebase-admin
25+
26+
# --- PYTHON SECTION (Using a Shell Loop) ---
27+
- name: Update specific Python packages
28+
run: |
29+
# Fetch latest versions from PyPI
30+
FF_LATEST=$(curl -s https://pypi.org/pypi/firebase-functions/json | grep -oP '"version":"\K[^"]+')
31+
FA_LATEST=$(curl -s https://pypi.org/pypi/firebase-admin/json | grep -oP '"version":"\K[^"]+')
32+
33+
# Find all requirements.txt files
34+
find . -name "requirements.txt" -not -path "*/.venv/*" -type f | while read -r file; do
35+
echo "Processing $file..."
36+
37+
# If firebase-functions is in the file, update its version
38+
if grep -q "firebase-functions" "$file"; then
39+
# Replace exact version matches like firebase-functions==1.0.0 or just firebase-functions
40+
# using sed. We will replace the whole line matching firebase-functions (optionally with version)
41+
# and put the memory guideline recommended ~= operator
42+
sed -i -E "s/^firebase-functions([=~<>].*)?$/firebase-functions~=$FF_LATEST/" "$file"
43+
fi
44+
45+
# If firebase-admin is in the file, update its version
46+
if grep -q "firebase-admin" "$file"; then
47+
sed -i -E "s/^firebase-admin([=~<>].*)?$/firebase-admin~=$FA_LATEST/" "$file"
48+
fi
49+
done
50+
51+
# --- COMMIT & PR SECTION ---
52+
- name: Create Pull Request
53+
run: |
54+
if git diff --quiet; then
55+
echo "No dependency updates found."
56+
else
57+
git config --global user.name 'github-actions[bot]'
58+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
59+
git checkout -b update-firebase-deps
60+
git commit -am "chore: targeted update of firebase-functions and firebase-admin"
61+
git push origin update-firebase-deps --force
62+
63+
# Check if PR already exists before creating
64+
if gh pr list --state open --head update-firebase-deps | grep -q "update-firebase-deps"; then
65+
echo "Pull request already exists."
66+
else
67+
gh pr create \
68+
--title "🚀 Targeted Dependency Updates (Firebase)" \
69+
--body "This PR updates \`firebase-functions\` and \`firebase-admin\` to their latest versions across all Node.js and Python subdirectories." \
70+
--base main \
71+
--head update-firebase-deps
72+
fi
73+
fi
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)