mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-26 15:31:53 +00:00
906cf0e1da
As `gh stack link --open` creates the PRs itself, it titles them after the branch name (i.e. `chore/static data/mise registry`) and fills in the default PR template, which isn't useful for these automated PRs. Instead, we can create each PR ourselves, using the commit's subject as the title and the commit body (or an empty string) as the PR body. As each branch holds a single commit on top of the previous branch, we base each PR on the previous branch in the stack. `gh stack link` is then used without `--open`, to link the existing PRs into a stack, which is still only done when there are at least two. Co-Authored-By: Claude Sonnet 5.5 <jamie.tanna+claude-code@mend.io>
90 lines
3.0 KiB
YAML
90 lines
3.0 KiB
YAML
name: 'Update static data'
|
|
on:
|
|
schedule:
|
|
- cron: '0 6 * * 1' # Every Monday at 06:00 UTC
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
NODE_VERSION: 24
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
update-data:
|
|
runs-on: ubuntu-latest
|
|
if: github.repository == 'renovatebot/renovate'
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
show-progress: false
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3.1.2
|
|
with:
|
|
install: false
|
|
runtime: node@${{ env.NODE_VERSION }}
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Install mise
|
|
uses: jdx/mise-action@82a612c5ab8bcda7cc5db6b7e81a8e7584c3dc6e # v5.2.3
|
|
with:
|
|
# don't run `mise install`, but do install a version of `mise` itself
|
|
install: false
|
|
|
|
- name: Configure git
|
|
run: |
|
|
git config user.name 'github-actions[bot]'
|
|
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
|
|
|
- name: Update static data
|
|
id: update
|
|
# the pre-commit hook refuses commits on `main`, so commit onto a working branch
|
|
run: |
|
|
git checkout -b chore/static-data-update
|
|
pnpm run update-static-data --commit
|
|
|
|
- name: Create stacked pull requests
|
|
if: steps.update.outputs.branches != ''
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
BRANCHES: ${{ steps.update.outputs.branches }}
|
|
run: |
|
|
gh extension install github/gh-stack --pin v0.2.1
|
|
gh auth setup-git
|
|
|
|
# any unmerged PRs from a previous run are superseded by this run
|
|
gh pr list --state open --json number,headRefName \
|
|
--jq '.[] | select(.headRefName | startswith("chore/static-data/")) | "\(.number) \(.headRefName)"' |
|
|
while read -r pr branch; do
|
|
gh pr close "$pr" --comment 'Superseded by a newer static data update.'
|
|
# not via `--delete-branch`, as that would also delete the new local branch
|
|
git push origin --delete "$branch"
|
|
done
|
|
|
|
read -ra branches <<< "$BRANCHES"
|
|
git push --force origin "${branches[@]}"
|
|
|
|
# each branch holds a single commit on top of the previous one, which provides the PR title and body
|
|
base=main
|
|
for branch in "${branches[@]}"; do
|
|
gh pr create --head "$branch" --base "$base" \
|
|
--title "$(git log -1 --format=%s "$branch")" \
|
|
--body "$(git log -1 --format=%b "$branch")"
|
|
base=$branch
|
|
done
|
|
|
|
# a stack needs at least two PRs
|
|
if [ "${#branches[@]}" -gt 1 ]; then
|
|
gh stack link "${branches[@]}"
|
|
fi
|
|
|
|
for branch in "${branches[@]}"; do
|
|
gh pr edit "$branch" --add-assignee viceice,secustor,jamietanna
|
|
done
|