A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
fix(ci): use a github app for the promote workflow
Hampus Kraftc50a74db7b55
diff --git a/.github/workflows/promote-canary-to-main.yaml b/.github/workflows/promote-canary-to-main.yamlindex e1eea3dd1..0a5eea41c 100644--- a/.github/workflows/promote-canary-to-main.yaml+++ b/.github/workflows/promote-canary-to-main.yaml@@ -21,7 +21,7 @@ concurrency:cancel-in-progress: falsepermissions:- contents: write+ contents: readjobs:promote:@@ -29,59 +29,53 @@ jobs:timeout-minutes: 10steps:- - name: Checkout source branch+ - name: Create GitHub App token+ id: app-token+ uses: actions/create-github-app-token@v1+ with:+ app-id: ${{ secrets.PROMOTE_APP_ID }}+ private-key: ${{ secrets.PROMOTE_APP_PRIVATE_KEY }}++ - name: Checkout sourceuses: actions/checkout@v6with:ref: ${{ inputs.src }}fetch-depth: 0- persist-credentials: true-- - name: Configure git identity- run: |- git config user.name "github-actions[bot]"- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"+ token: ${{ steps.app-token.outputs.token }}- - name: Fetch destination branch- run: |- set -euo pipefail- git fetch origin "${{ inputs.dst }}" --prune --tags-- - name: Verify FF-only + write summary+ - name: Verify ff-only + summarizeid: verifyrun: |set -euo pipefailsrc="${{ inputs.src }}"dst="${{ inputs.dst }}"- SRC_SHA="$(git rev-parse HEAD)"- DST_SHA="$(git rev-parse "origin/${dst}")"+ git fetch origin "${dst}" "${src}" --prune- echo "src=$src" >> "$GITHUB_OUTPUT"- echo "dst=$dst" >> "$GITHUB_OUTPUT"- echo "src_sha=$SRC_SHA" >> "$GITHUB_OUTPUT"- echo "dst_sha=$DST_SHA" >> "$GITHUB_OUTPUT"+ # Ensure HEAD is exactly origin/src+ git reset --hard "origin/${src}"- # Ensure main is an ancestor of canary => fast-forward is possible- if ! git merge-base --is-ancestor "origin/${dst}" HEAD; then- echo "::error::Cannot fast-forward: origin/${dst} is not an ancestor of ${src}. Branches have diverged."+ # FF-only requirement: dst must be an ancestor of src+ if ! git merge-base --is-ancestor "origin/${dst}" "origin/${src}"; then+ echo "::error::Cannot fast-forward: origin/${dst} is not an ancestor of origin/${src} (branches diverged)."exit 1fi- ahead="$(git rev-list --count "origin/${dst}..HEAD")"+ ahead="$(git rev-list --count "origin/${dst}..origin/${src}")"echo "ahead=$ahead" >> "$GITHUB_OUTPUT"{echo "## Promote \`${src}\` → \`${dst}\` (ff-only)"echo ""- echo "- ${dst}: \`${DST_SHA}\`"- echo "- ${src}: \`${SRC_SHA}\`"+ echo "- \`${dst}\`: \`$(git rev-parse "origin/${dst}")\`"+ echo "- \`${src}\`: \`$(git rev-parse "origin/${src}")\`"echo "- Commits to promote: **${ahead}**"echo ""echo "### Commits"if [ "$ahead" -eq 0 ]; thenecho "_Nothing to promote._"else- git log --oneline --decorate "origin/${dst}..HEAD"+ git log --oneline --decorate "origin/${dst}..origin/${src}"fi} >> "$GITHUB_STEP_SUMMARY"@@ -89,7 +83,8 @@ jobs:if: ${{ steps.verify.outputs.ahead != '0' && inputs.dry_run != true }}run: |set -euo pipefail- dst="${{ steps.verify.outputs.dst }}"+ dst="${{ inputs.dst }}"+ # Push src HEAD to dst (no merge commit, same SHAs)git push origin "HEAD:refs/heads/${dst}"- name: Dry run / no-op