-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (60 loc) · 2.53 KB
/
Copy pathupdate-pp-dev.yml
File metadata and controls
73 lines (60 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Update pp-dev Dependency
on:
workflow_dispatch:
schedule:
- cron: '0 */6 * * *' # Every 6 hours
permissions:
contents: write
pull-requests: write
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
- name: Check for pp-dev updates
id: check
run: |
CURRENT=$(node -p "require('./package.json').devDependencies['@metricinsights/pp-dev'].replace('^', '')")
LATEST=$(npm view @metricinsights/pp-dev version)
echo "current=$CURRENT" >> $GITHUB_OUTPUT
echo "latest=$LATEST" >> $GITHUB_OUTPUT
# Only update when the published version is actually newer — a plain "!=" would also
# fire (and downgrade us) if CURRENT is pinned ahead of what's published (e.g. a pre-release
# major bump landed here before npm caught up).
if [ "$CURRENT" != "$LATEST" ] && [ "$(printf '%s\n%s\n' "$CURRENT" "$LATEST" | sort -V | tail -1)" = "$LATEST" ]; then
echo "needs_update=true" >> $GITHUB_OUTPUT
else
echo "needs_update=false" >> $GITHUB_OUTPUT
fi
- name: Update dependency
if: steps.check.outputs.needs_update == 'true'
run: |
VERSION=${{ steps.check.outputs.latest }}
# Update package.json
npm pkg set devDependencies.@metricinsights/pp-dev="^$VERSION"
# Update all template package.json files
find template-* -name "package.json" -exec sed -i \
"s/\"@metricinsights\/pp-dev\": \"[^\"]*\"/\"@metricinsights\/pp-dev\": \"^$VERSION\"/g" {} \;
- name: Update package-lock.json
if: steps.check.outputs.needs_update == 'true'
run: npm install --package-lock-only
- name: Create Pull Request
if: steps.check.outputs.needs_update == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.PAT_TOKEN }}
commit-message: 'chore(deps): update @metricinsights/pp-dev to ${{ steps.check.outputs.latest }}'
title: 'chore(deps): update pp-dev to ${{ steps.check.outputs.latest }}'
body: |
Automated update of @metricinsights/pp-dev dependency.
- Previous: ${{ steps.check.outputs.current }}
- New: ${{ steps.check.outputs.latest }}
branch: deps/update-pp-dev
delete-branch: true