Skip to content

Commit 4b397e4

Browse files
CopilotIEvangelistCopilot
authored
Add daily workflow to merge main into the active release branch (#738)
* Add daily release branch update workflow Agent-Logs-Url: https://github.com/microsoft/aspire.dev/sessions/5aa81bbc-530e-484c-99dd-c568a96680c5 Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com> Co-authored-by: David Pine <david.pine@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 12f1da5 commit 4b397e4

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Update Release Branch
2+
3+
on:
4+
schedule:
5+
# Runs daily at 04:00 UTC
6+
- cron: '0 4 * * *'
7+
workflow_dispatch:
8+
9+
permissions: {}
10+
11+
concurrency:
12+
group: update-release-branch
13+
cancel-in-progress: false
14+
15+
jobs:
16+
update-release-branch:
17+
name: Merge main into active release branch
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
21+
steps:
22+
- name: Create GitHub App Token
23+
id: app-token
24+
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3
25+
with:
26+
app-id: ${{ secrets.ASPIRE_BOT_APP_ID }}
27+
private-key: ${{ secrets.ASPIRE_BOT_PRIVATE_KEY }}
28+
owner: ${{ github.repository_owner }}
29+
repositories: ${{ github.event.repository.name }}
30+
github-api-url: ${{ github.api_url }}
31+
permission-contents: write
32+
33+
- name: Find active release branch
34+
id: find-branch
35+
env:
36+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
37+
shell: bash
38+
run: |
39+
# Fetch all branches matching release/{major}.{minor} and pick the
40+
# latest by version sort.
41+
if ! branches=$(gh api "repos/${{ github.repository }}/branches" \
42+
--paginate \
43+
--jq '.[].name'); then
44+
echo "::error::Failed to query repository branches via gh api."
45+
exit 1
46+
fi
47+
48+
branch=$(printf '%s\n' "$branches" \
49+
| grep -E '^release/[0-9]+\.[0-9]+$' \
50+
| sort -V \
51+
| tail -1 || true)
52+
53+
if [[ -z "$branch" ]]; then
54+
echo "No active release branch found. Nothing to do."
55+
echo "branch=" >> "$GITHUB_OUTPUT"
56+
else
57+
echo "Active release branch: $branch"
58+
echo "branch=$branch" >> "$GITHUB_OUTPUT"
59+
fi
60+
61+
- name: Checkout release branch
62+
if: ${{ steps.find-branch.outputs.branch != '' }}
63+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
64+
with:
65+
ref: ${{ steps.find-branch.outputs.branch }}
66+
token: ${{ steps.app-token.outputs.token }}
67+
fetch-depth: 0
68+
69+
- name: Configure git identity
70+
if: ${{ steps.find-branch.outputs.branch != '' }}
71+
shell: bash
72+
run: |
73+
git config user.name "github-actions[bot]"
74+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
75+
76+
- name: Merge main into release branch
77+
if: ${{ steps.find-branch.outputs.branch != '' }}
78+
shell: bash
79+
run: |
80+
git fetch origin main
81+
if git merge origin/main --no-edit; then
82+
echo "Merged main into ${{ steps.find-branch.outputs.branch }} successfully."
83+
git push
84+
else
85+
echo "::error::Merge conflict detected between main and ${{ steps.find-branch.outputs.branch }}. Manual intervention required."
86+
git merge --abort
87+
exit 1
88+
fi

0 commit comments

Comments
 (0)