Skip to content

Commit 98d376c

Browse files
committed
Enhance PR automation workflow with improved permissions and dynamic labeling for validation and test results
1 parent 21a61e9 commit 98d376c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

.github/workflows/pr-automation.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
types: [opened, synchronize, reopened]
66
branches: [main]
77

8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
issues: write
12+
813
jobs:
914
# Run all tests and validations
1015
run-tests:
@@ -128,9 +133,14 @@ jobs:
128133
steps:
129134
- name: 🎃 Add Hacktoberfest labels and welcome contributors
130135
uses: actions/github-script@v7
136+
env:
137+
VALIDATION_PASSED: ${{ needs.run-tests.outputs.validation-passed }}
138+
TESTS_PASSED: ${{ needs.run-tests.outputs.tests-passed }}
131139
with:
132140
script: |
133141
const { owner, repo, number } = context.issue;
142+
const validationPassed = process.env.VALIDATION_PASSED === 'true';
143+
const testsPassed = process.env.TESTS_PASSED === 'true';
134144
135145
// Get PR and contributor info
136146
const pr = await github.rest.pulls.get({ owner, repo, pull_number: number });
@@ -172,7 +182,7 @@ jobs:
172182
if (files.data.length > 5) labels.push('advanced');
173183
174184
// Add status labels
175-
if (needs.run-tests.outputs.tests-passed === 'true') {
185+
if (testsPassed) {
176186
labels.push('tests-passing');
177187
} else {
178188
labels.push('needs-work');
@@ -198,11 +208,11 @@ jobs:
198208
Thank you for your first contribution to our DSA repository! Here's what happens next:
199209
200210
## 🔍 Automatic Checks
201-
- ✅ **Code Validation**: ${needs.run-tests.outputs.validation-passed === 'true' ? 'Passed' : 'Failed'}
202-
- 🧪 **Compilation Tests**: ${needs.run-tests.outputs.tests-passed === 'true' ? 'Passed' : 'Failed'}
211+
- ✅ **Code Validation**: ${validationPassed ? 'Passed' : 'Failed'}
212+
- 🧪 **Compilation Tests**: ${testsPassed ? 'Passed' : 'Failed'}
203213
204214
## 📋 Next Steps
205-
${needs.run-tests.outputs.tests-passed === 'true' ?
215+
${testsPassed ?
206216
'🎯 **Great job!** Your code compiled successfully. A maintainer will review your PR soon.' :
207217
'⚠️ **Action needed**: Please fix the compilation errors and push your changes.'}
208218

0 commit comments

Comments
 (0)