name: Sync Rebuild Triggers # Rebuilds ride the unattended lane, like track-branches.yml: the pkgrel bump # PR builds on the droplets, auto-merge lands it once `result`, `self-tests` # and `build-isolation` are green, and the merge publishes. A rebuild that # fails stays an unmerged red PR for a maintainer. # # The PR and auto-merge use the PAT in PKGS_BOT_TOKEN, because a merge made # with the built-in GITHUB_TOKEN does not start publish.yml, and its pushes # are held for approval instead of building. on: schedule: # Every 6 hours, off the hour to dodge the scheduling backlog at :00 - cron: '40 */6 * * *' workflow_dispatch: inputs: packages: description: 'Specific packages to update (space-separated, leave empty for all)' required: false default: '' jobs: sync: runs-on: ubuntu-latest permissions: contents: write pull-requests: write steps: - name: Require the bot token env: PKGS_BOT_TOKEN: ${{ secrets.PKGS_BOT_TOKEN }} run: | if [[ -z "$PKGS_BOT_TOKEN" ]]; then echo "::error::Set PKGS_BOT_TOKEN to a PAT with Contents: write and Pull requests: write on this repository, owned by an account trusted to trigger builds." exit 1 fi - name: Checkout repository uses: actions/checkout@v4 with: persist-credentials: false # A scoped dispatch regenerates only the named packages. Pushed to the # shared branch, that would replace every other pending update in its # PR, so it gets a branch and PR of its own. - name: Choose the PR branch id: branch env: PACKAGES: ${{ github.event.inputs.packages }} run: | read -r -a package_args <<< "${PACKAGES:-}" .github/scripts/sync-pr-branch.sh auto/sync-rebuilds "${package_args[@]}" | tee -a "$GITHUB_OUTPUT" # Runs in an Arch container against the mirror the x86_64 builder itself # uses, because the question being asked is what that builder will link # against and a different mirror can be hours ahead of it. Recording a # version the build never saw is the one failure this command must not # have: nothing re-fires once the record matches. - name: Bump pkgrel for packages whose dependencies moved run: | docker run --rm \ -e PACKAGES="$PACKAGES" \ -e HOST_UID="$(id -u)" \ -e HOST_GID="$(id -g)" \ -v "$PWD/bin:/workspace/bin:ro" \ -v "$PWD/helpers:/workspace/helpers:ro" \ -v "$PWD/pkgbuilds:/workspace/pkgbuilds" \ -w /workspace \ archlinux:base-devel bash -lc ' set -euo pipefail printf "Server = https://mirror.omarchy.org/\$repo/os/\$arch\n" > /etc/pacman.d/mirrorlist pacman -Syu --noconfirm jq groupadd -g "$HOST_GID" runner useradd -m -u "$HOST_UID" -g "$HOST_GID" runner chown -R runner:runner /workspace/pkgbuilds if [[ -n "${PACKAGES:-}" ]]; then read -r -a package_args <<< "$PACKAGES" runuser -u runner -- ./bin/sync-rebuilds "${package_args[@]}" else runuser -u runner -- ./bin/sync-rebuilds fi ' env: PACKAGES: ${{ github.event.inputs.packages }} - name: Check for changes id: changes run: | if [ -z "$(git status --porcelain)" ]; then echo "has_changes=false" >> "$GITHUB_OUTPUT" else echo "has_changes=true" >> "$GITHUB_OUTPUT" fi - name: Create Pull Request if: steps.changes.outputs.has_changes == 'true' id: cpr uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.PKGS_BOT_TOKEN }} commit-message: 'chore: rebuild against updated dependencies' title: "chore: rebuild against updated dependencies${{ steps.branch.outputs.scope && format(' ({0})', steps.branch.outputs.scope) || '' }}" body: | Automated pkgrel bump for packages that link against a dependency which has moved in the official repositories. Each package names those dependencies in `rebuild_on` and carries the versions its current pkgrel was bumped for in `rebuilt_against`. The bump is what makes the rebuilt package an upgrade pacman will offer; without it the build produces the version already published and no one receives it. This PR auto-merges once the build checks pass. A failing rebuild leaves it open for a maintainer. branch: ${{ steps.branch.outputs.branch }} delete-branch: true labels: automated # Auto-merge, not a direct merge: branch protection still has to see # the build checks green before the rebuild lands. - name: Enable auto-merge if: steps.cpr.outputs.pull-request-number != '' env: GH_TOKEN: ${{ secrets.PKGS_BOT_TOKEN }} PR: ${{ steps.cpr.outputs.pull-request-number }} run: | # Idempotent across re-runs of an updated PR: enabling twice errors. if [[ "$(gh pr view "$PR" -R "${{ github.repository }}" --json autoMergeRequest --jq '.autoMergeRequest != null')" == true ]]; then echo "auto-merge already enabled on #$PR" exit 0 fi gh pr merge --auto --merge "$PR" -R "${{ github.repository }}" - name: Notify Basecamp on failure if: failure() && env.BASECAMP_CHATBOT_URL != '' env: BASECAMP_CHATBOT_URL: ${{ secrets.BASECAMP_CHATBOT_URL }} run: | curl -s -o /dev/null \ -H "Content-Type: application/json" \ -d "$(jq -n --arg content \ "🔴 Rebuild trigger sync failed
View run" \ '{content: $content}')" \ "$BASECAMP_CHATBOT_URL"