Repository navigation
52 lines (46 loc) · 2.09 KB
/
Copy pathrelease-sync.yml
File metadata and controls
52 lines (46 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Release sync
# `release` is generated here, not maintained: every push to develop rebuilds it
# as one commit on top of that develop commit (develop minus the Markdown files
# that must not reach main), force-pushes it, and keeps one release -> main PR open.
on:
push:
branches: [develop]
permissions:
contents: write
pull-requests: write
concurrency:
group: release-sync
cancel-in-progress: false
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sync release branch
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Not used as a base (release is regenerated); the script reads the
# remote sha itself for --force-with-lease.
bash .github/scripts/release/sync-release.sh --source "${GITHUB_SHA}" --push
- name: Open or update PR release -> main
env:
# Needs "Allow GitHub Actions to create and approve pull requests" in the
# repository's Actions settings. RELEASE_PR_TOKEN is optional.
GH_TOKEN: ${{ secrets.RELEASE_PR_TOKEN || github.token }}
run: |
set -eu
if ! git rev-parse -q --verify refs/heads/release >/dev/null; then exit 0; fi
if [ "$(git rev-parse release^{tree})" = "$(git rev-parse origin/main^{tree} 2>/dev/null || true)" ]; then
echo "release already equals main; nothing to PR"; exit 0
fi
title="Release: merge release into main"
body="Automated sync of \`develop\` (${GITHUB_SHA::7}) into \`release\`. Markdown outside README.md and docs/ subfolders is removed by .github/scripts/release/sync-release.sh."
existing="$(gh pr list --head release --base main --state open --json number --jq '.[0].number // empty')"
if [ -n "$existing" ]; then
gh pr edit "$existing" --title "$title" --body "$body"
else
gh pr create --head release --base main --title "$title" --body "$body"
fi