Consolidate Renovate artifact workflows (#7252)

This commit is contained in:
2026-06-15 09:15:26 -07:00
committed by GitHub
parent fd29767921
commit 4026e76a37
2 changed files with 114 additions and 79 deletions
@@ -1,4 +1,4 @@
name: Renovate Bazel Lockfile
name: Renovate Dependency Artifacts
on:
pull_request:
@@ -10,7 +10,7 @@ on:
- 'renovate.json'
- 'ci/github_actions/ensure_bazel_installed.sh'
- '.github/actions/setup-bazel/**'
- '.github/workflows/renovate_bazel_lockfile.yml'
- '.github/workflows/renovate_dependency_artifacts.yml'
pull_request_target:
types: [opened, reopened, synchronize, ready_for_review]
@@ -18,10 +18,12 @@ on:
- 'MODULE.bazel'
- 'MODULE.bazel.lock'
- 'maven_install.json'
- 'go.mod'
- 'go.sum'
- 'renovate.json'
- 'ci/github_actions/ensure_bazel_installed.sh'
- '.github/actions/setup-bazel/**'
- '.github/workflows/renovate_bazel_lockfile.yml'
- '.github/workflows/renovate_dependency_artifacts.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.head.ref }}
@@ -32,6 +34,54 @@ permissions:
pull-requests: read
jobs:
changes:
if: github.event_name == 'pull_request_target'
runs-on: ubuntu-latest
outputs:
bazel: ${{ steps.changed-files.outputs.bazel }}
go: ${{ steps.changed-files.outputs.go }}
steps:
- name: Detect changed dependency files
id: changed-files
uses: actions/github-script@v9
with:
script: |
const files = await github.paginate(
github.rest.pulls.listFiles,
{
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
per_page: 100,
},
);
const changed = files.map((file) => file.filename);
const bazelPatterns = [
/^MODULE\.bazel$/,
/^MODULE\.bazel\.lock$/,
/^maven_install\.json$/,
/^renovate\.json$/,
/^ci\/github_actions\/ensure_bazel_installed\.sh$/,
/^\.github\/actions\/setup-bazel\//,
/^\.github\/workflows\/renovate_dependency_artifacts\.yml$/,
];
const goPatterns = [
/^go\.mod$/,
/^go\.sum$/,
/^renovate\.json$/,
/^\.github\/workflows\/renovate_dependency_artifacts\.yml$/,
];
core.setOutput(
'bazel',
changed.some((file) => bazelPatterns.some((pattern) => pattern.test(file))),
);
core.setOutput(
'go',
changed.some((file) => goPatterns.some((pattern) => pattern.test(file))),
);
check-lockfile:
if: >-
github.event_name == 'pull_request' &&
@@ -71,10 +121,12 @@ jobs:
exit 1
update-lockfile:
needs: changes
if: >-
github.event.pull_request.user.login == 'renovate[bot]' &&
github.event.pull_request.head.repo.full_name == github.repository &&
startsWith(github.event.pull_request.head.ref, 'renovate/')
startsWith(github.event.pull_request.head.ref, 'renovate/') &&
needs.changes.outputs.bazel == 'true'
runs-on: [self-hosted, bazel]
steps:
@@ -127,3 +179,61 @@ jobs:
git add MODULE.bazel.lock maven_install.json
git commit -m "Update generated dependency lockfiles"
git push origin "HEAD:${{ github.event.pull_request.head.ref }}"
update-go-artifacts:
needs: changes
if: >-
github.event.pull_request.user.login == 'renovate[bot]' &&
github.event.pull_request.head.repo.full_name == github.repository &&
startsWith(github.event.pull_request.head.ref, 'renovate/') &&
needs.changes.outputs.go == 'true'
runs-on: [self-hosted, bazel]
steps:
- name: Ensure Git LFS available for checkout
run: |
COMMON_PATHS=(/opt/homebrew/bin /usr/local/bin)
for path in "${COMMON_PATHS[@]}"; do
if [ -d "$path" ]; then
echo "$path" >> "$GITHUB_PATH"
export PATH="$path:$PATH"
fi
done
if command -v git-lfs >/dev/null 2>&1; then
git-lfs version
exit 0
fi
brew install git-lfs
git-lfs version
- name: Checkout Renovate branch
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
token: ${{ secrets.RENOVATE_LOCKFILE_TOKEN || github.token }}
lfs: false
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: false
- name: Update Go module sums
run: go mod download all
- name: Commit generated Go artifact updates
run: |
if git diff --quiet -- go.sum; then
echo "Go artifacts are already up to date"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add go.sum
git commit -m "Update generated Go artifacts"
git push origin "HEAD:${{ github.event.pull_request.head.ref }}"
@@ -1,75 +0,0 @@
name: Renovate Go Artifacts
on:
pull_request_target:
types: [opened, reopened, synchronize, ready_for_review]
paths:
- 'go.mod'
- 'go.sum'
- 'renovate.json'
- '.github/workflows/renovate_go_artifacts.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.head.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: read
jobs:
update-go-artifacts:
if: >-
github.event.pull_request.user.login == 'renovate[bot]' &&
github.event.pull_request.head.repo.full_name == github.repository &&
startsWith(github.event.pull_request.head.ref, 'renovate/')
runs-on: [self-hosted, bazel]
steps:
- name: Ensure Git LFS available for checkout
run: |
COMMON_PATHS=(/opt/homebrew/bin /usr/local/bin)
for path in "${COMMON_PATHS[@]}"; do
if [ -d "$path" ]; then
echo "$path" >> "$GITHUB_PATH"
export PATH="$path:$PATH"
fi
done
if command -v git-lfs >/dev/null 2>&1; then
git-lfs version
exit 0
fi
brew install git-lfs
git-lfs version
- name: Checkout Renovate branch
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
token: ${{ secrets.RENOVATE_LOCKFILE_TOKEN || github.token }}
lfs: false
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: false
- name: Update Go module sums
run: go mod download all
- name: Commit generated Go artifact updates
run: |
if git diff --quiet -- go.sum; then
echo "Go artifacts are already up to date"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add go.sum
git commit -m "Update generated Go artifacts"
git push origin "HEAD:${{ github.event.pull_request.head.ref }}"