Skip to content

Commit 8cd4b01

Browse files
authored
chore: automate js assets updates (#8897)
Drop the orphan package-lock.json that made Dependabot security updates fail. A monthly workflow runs tools/update-js.sh and opens a pull request on 5.0, and Dependabot github-actions updates now target 5.0 so they reach main through the merge-up.
1 parent ea790d4 commit 8cd4b01

4 files changed

Lines changed: 59 additions & 3471 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ updates:
44
# Maintain dependencies for GitHub Actions
55
- package-ecosystem: github-actions
66
directory: /
7+
target-branch: '5.0'
78
schedule:
89
interval: monthly

‎.github/workflows/update-js.yml‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Update JS assets
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 1 * *'
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
env:
12+
BASE_BRANCH: '5.0'
13+
UPDATE_BRANCH: chore/update-js-assets
14+
15+
jobs:
16+
update-js:
17+
name: Update JS assets
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Generate App Token
21+
id: generate_token
22+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
23+
with:
24+
app_id: ${{ secrets.API_PLATFORM_APP_ID }}
25+
private_key: ${{ secrets.API_PLATFORM_APP_PRIVATE_KEY }}
26+
27+
- name: Checkout
28+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
29+
with:
30+
ref: ${{ env.BASE_BRANCH }}
31+
token: ${{ steps.generate_token.outputs.token }}
32+
33+
- name: Setup node
34+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
35+
with:
36+
node-version: 'lts/*'
37+
38+
- name: Update assets
39+
run: tools/update-js.sh
40+
41+
- name: Open pull request
42+
env:
43+
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
44+
run: |
45+
if [ -z "$(git status --porcelain)" ]; then
46+
echo 'JS assets are up to date.'
47+
exit 0
48+
fi
49+
git config user.name 'api-platform-bot'
50+
git config user.email 'api-platform-bot@users.noreply.github.com'
51+
git switch -C "$UPDATE_BRANCH"
52+
git add -A src/Symfony/Bundle/Resources/public src/Laravel/public
53+
git commit -m 'chore: update swagger-ui, redoc and open-sans assets'
54+
git push --force origin "$UPDATE_BRANCH"
55+
if [ -z "$(gh pr list --head "$UPDATE_BRANCH" --base "$BASE_BRANCH" --state open --json number --jq '.[].number')" ]; then
56+
gh pr create --base "$BASE_BRANCH" --head "$UPDATE_BRANCH" --title 'chore: update swagger-ui, redoc and open-sans assets' --body 'Generated by `tools/update-js.sh` (`.github/workflows/update-js.yml`).'
57+
fi

0 commit comments

Comments
 (0)