Autoupdate wraps #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Autoupdate wraps | |
on: | |
schedule: | |
- cron: "15 0 * * 0" | |
- cron: "15 0 * * 4" | |
workflow_dispatch: | |
inputs: | |
wraps: | |
description: Update only these wraps (space-separated, optional) | |
required: false | |
type: string | |
permissions: | |
# everything uses personal access tokens | |
contents: none | |
concurrency: autoupdate | |
env: | |
# repo to send PRs to | |
BASE_REPO: mesonbuild/wrapdb | |
# repo to send PRs from | |
HEAD_REPO: wrapdb-bot/wrapdb | |
# Tokens: | |
# BASE_TOKEN | |
# Classic token with public_repo scope, for accessing BASE_REPO. | |
# HEAD_TOKEN | |
# Fine-grained token with R/W code + workflow access to HEAD_REPO. | |
# Workflow access is needed for syncing upstream commits that update | |
# GitHub Actions workflows. This is safe because GitHub Actions is | |
# disabled in HEAD_REPO. | |
# KEEPALIVE_TOKEN | |
# R/W actions access to this repo, for refreshing the 60-day workflow | |
# timeout. | |
jobs: | |
check: | |
name: Check for updates | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.check.outputs.matrix }} | |
steps: | |
- name: Check out base repo | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.BASE_TOKEN }} | |
repository: ${{ env.BASE_REPO }} | |
- name: Check for updates | |
id: check | |
run: | | |
tools/versions.py list --github --official --update ${{ inputs.wraps }} | \ | |
sed 's/^matrix=//' | \ | |
jq -c '{"include": .include | map(select(.wrap | in({"blueprint-compiler":1, "pango":1, "qarchive":1, "tracy":1}) | not))}' | \ | |
sed 's/^/matrix=/' >> $GITHUB_OUTPUT | |
- name: Report untracked wraps | |
run: | | |
echo "## Manual update required" >> $GITHUB_STEP_SUMMARY | |
tools/versions.py list --markdown --port --update >> $GITHUB_STEP_SUMMARY | |
echo "## Not configured in [Anitya](https://release-monitoring.org/)" >> $GITHUB_STEP_SUMMARY | |
tools/versions.py list --markdown --untracked >> $GITHUB_STEP_SUMMARY | |
- name: Delete stale branches | |
env: | |
GITHUB_TOKEN: ${{ secrets.HEAD_TOKEN }} | |
run: | | |
tools/versions.py list --json --official --update | \ | |
jq -r "keys | .[]" | \ | |
sed "s:^:auto/:" > expected-branches | |
# delete unneeded auto branches, which closes any corresponding PRs | |
gh api "/repos/${{ env.HEAD_REPO }}/branches" -q .[].name | \ | |
grep "^auto/" | \ | |
grep -Fvxf expected-branches | \ | |
sed "s/^/:/" | \ | |
xargs -r git push "${{ github.server_url }}/${{ env.HEAD_REPO }}" | |
# Prevent GitHub from disabling the workflow after 60 days | |
- name: Keep workflow alive | |
env: | |
GITHUB_TOKEN: ${{ secrets.KEEPALIVE_TOKEN }} | |
run: gh workflow enable -R ${{ github.repository }} autoupdate.yml | |
update: | |
name: Update | |
needs: check | |
runs-on: ubuntu-latest | |
if: fromJson(needs.check.outputs.matrix).include[0] | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.check.outputs.matrix) }} | |
steps: | |
- name: Check out base repo | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.BASE_TOKEN }} | |
repository: ${{ env.BASE_REPO }} | |
- name: Update | |
run: tools/versions.py autoupdate "${{ matrix.wrap }}" | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.BASE_TOKEN }} | |
branch-token: ${{ secrets.HEAD_TOKEN }} | |
push-to-fork: ${{ env.HEAD_REPO }} | |
branch: auto/${{ matrix.wrap }} | |
title: "${{ matrix.wrap }}: update from ${{ matrix.old-version }} to ${{ matrix.new-version }}" | |
body: "[Automated PR](${{ github.server_url }}/${{ github.repository }}/actions/workflows/autoupdate.yml) by WrapDB Bot." | |
commit-message: "${{ matrix.wrap }}: update from ${{ matrix.old-version }} to ${{ matrix.new-version }}" | |
author: "WrapDB Bot <[email protected]>" | |
committer: "WrapDB Bot <[email protected]>" | |
maintainer-can-modify: false |