Skip to content

Commit 140a110

Browse files
Copilotleaanthony
andauthored
Fix workflow permissions: add actions:write to unreleased-changelog-trigger.yml (#4553)
* Initial plan * Fix workflow permissions: add actions:write to unreleased-changelog-trigger.yml Co-authored-by: leaanthony <1943904+leaanthony@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: leaanthony <1943904+leaanthony@users.noreply.github.com>
1 parent bc3299f commit 140a110

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: Auto Release on Changelog Update
2+
3+
on:
4+
push:
5+
branches:
6+
- v3-alpha
7+
paths:
8+
- 'v3/UNRELEASED_CHANGELOG.md'
9+
workflow_dispatch:
10+
inputs:
11+
dry_run:
12+
description: 'Run in dry-run mode (no actual release)'
13+
required: false
14+
default: false
15+
type: boolean
16+
17+
jobs:
18+
check-permissions:
19+
name: Check Release Permissions
20+
runs-on: ubuntu-latest
21+
outputs:
22+
authorized: ${{ steps.check.outputs.authorized }}
23+
steps:
24+
- name: Check if user is authorized for releases
25+
id: check
26+
run: |
27+
# Only allow specific users to trigger releases
28+
AUTHORIZED_USERS="leaanthony"
29+
30+
if [[ "$AUTHORIZED_USERS" == *"${{ github.actor }}"* ]]; then
31+
echo "✅ User ${{ github.actor }} is authorized for releases"
32+
echo "authorized=true" >> $GITHUB_OUTPUT
33+
else
34+
echo "❌ User ${{ github.actor }} is not authorized for releases"
35+
echo "authorized=false" >> $GITHUB_OUTPUT
36+
fi
37+
38+
trigger-release:
39+
name: Trigger v3-alpha Release
40+
permissions:
41+
contents: read
42+
actions: write
43+
runs-on: ubuntu-latest
44+
needs: check-permissions
45+
if: needs.check-permissions.outputs.authorized == 'true'
46+
steps:
47+
- name: Checkout code
48+
uses: actions/checkout@v4
49+
with:
50+
ref: v3-alpha
51+
fetch-depth: 0
52+
token: ${{ secrets.WAILS_REPO_TOKEN || github.token }}
53+
54+
- name: Check for unreleased changelog content
55+
id: changelog_check
56+
run: |
57+
echo "🔍 Checking UNRELEASED_CHANGELOG.md for content..."
58+
59+
cd v3
60+
# Check if UNRELEASED_CHANGELOG.md has actual content beyond the template
61+
if [ -f "UNRELEASED_CHANGELOG.md" ]; then
62+
# Use a simple check for actual content (bullet points starting with -)
63+
CONTENT_LINES=$(grep -E "^\s*-\s+[^[:space:]]" UNRELEASED_CHANGELOG.md | wc -l)
64+
if [ "$CONTENT_LINES" -gt 0 ]; then
65+
echo "✅ Found $CONTENT_LINES content lines in UNRELEASED_CHANGELOG.md"
66+
echo "has_content=true" >> $GITHUB_OUTPUT
67+
else
68+
echo "ℹ️ No actual content found in UNRELEASED_CHANGELOG.md"
69+
echo "has_content=false" >> $GITHUB_OUTPUT
70+
fi
71+
else
72+
echo "❌ UNRELEASED_CHANGELOG.md not found"
73+
echo "has_content=false" >> $GITHUB_OUTPUT
74+
fi
75+
76+
- name: Trigger nightly release workflow
77+
if: steps.changelog_check.outputs.has_content == 'true'
78+
uses: actions/github-script@v7
79+
with:
80+
github-token: ${{ secrets.WAILS_REPO_TOKEN || github.token }}
81+
script: |
82+
const response = await github.rest.actions.createWorkflowDispatch({
83+
owner: context.repo.owner,
84+
repo: context.repo.repo,
85+
workflow_id: 'nightly-release-v3.yml',
86+
ref: 'v3-alpha',
87+
inputs: {
88+
force_release: 'true',
89+
dry_run: '${{ github.event.inputs.dry_run || "false" }}'
90+
}
91+
});
92+
93+
console.log('🚀 Successfully triggered nightly release workflow');
94+
console.log(`Workflow dispatch response status: ${response.status}`);
95+
96+
// Create a summary
97+
core.summary
98+
.addHeading('🚀 Auto Release Triggered')
99+
.addRaw('The v3-alpha release workflow has been automatically triggered due to changes in UNRELEASED_CHANGELOG.md')
100+
.addTable([
101+
[{data: 'Trigger', header: true}, {data: 'Value', header: true}],
102+
['Repository', context.repo.repo],
103+
['Branch', 'v3-alpha'],
104+
['Actor', context.actor],
105+
['Dry Run', '${{ github.event.inputs.dry_run || "false" }}'],
106+
['Force Release', 'true']
107+
])
108+
.addRaw('\n---\n*This release was automatically triggered by the unreleased-changelog-trigger workflow*')
109+
.write();
110+
111+
- name: No content found
112+
if: steps.changelog_check.outputs.has_content == 'false'
113+
run: |
114+
echo "ℹ️ No content found in UNRELEASED_CHANGELOG.md, skipping release trigger"
115+
echo "## ℹ️ No Release Triggered" >> $GITHUB_STEP_SUMMARY
116+
echo "**Reason:** UNRELEASED_CHANGELOG.md does not contain actual changelog content" >> $GITHUB_STEP_SUMMARY
117+
echo "**Action:** No release workflow was triggered" >> $GITHUB_STEP_SUMMARY
118+
echo "" >> $GITHUB_STEP_SUMMARY
119+
echo "To trigger a release, add actual changelog entries to the UNRELEASED_CHANGELOG.md file." >> $GITHUB_STEP_SUMMARY
120+
121+
- name: Unauthorized user
122+
if: needs.check-permissions.outputs.authorized == 'false'
123+
run: |
124+
echo "❌ User ${{ github.actor }} is not authorized to trigger releases"
125+
echo "## ❌ Unauthorized Release Attempt" >> $GITHUB_STEP_SUMMARY
126+
echo "**User:** ${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
127+
echo "**Action:** Release trigger was blocked due to insufficient permissions" >> $GITHUB_STEP_SUMMARY
128+
echo "" >> $GITHUB_STEP_SUMMARY
129+
echo "Only authorized users can trigger automatic releases via changelog updates." >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)