55
66jobs :
77 get-delivery-files :
8- runs-on : ubuntu-latest
9- outputs :
10- filenames : ${{ steps.files.outputs.added }}
11-
12- steps :
13- - name : Get filenames of any deliveries being added
14- id : files
15- uses : Ana06/get-changed-files@v2.3.0
16- with :
17- format : ' json'
18- filter : |
19- deliveries/*.md
20- maintenance_deliveries/*.md
21-
8+ runs-on : ubuntu-latest
9+ outputs :
10+ filenames : ${{ steps.files.outputs.added }}
11+
12+ steps :
13+ - name : Get filenames of any deliveries being added
14+ id : files
15+ uses : Ana06/get-changed-files@v2.3.0
16+ with :
17+ format : ' json'
18+ filter : |
19+ deliveries/*.md
20+ maintenance_deliveries/*.md
21+
2222 check_author :
2323 runs-on : ubuntu-latest
2424 needs : get-delivery-files
@@ -27,34 +27,96 @@ jobs:
2727 fail-fast : false
2828 matrix :
2929 filename : ${{ fromJson(needs.get-delivery-files.outputs.filenames) }}
30-
30+
3131 steps :
3232 - uses : actions/checkout@v4
3333 with :
3434 ref : ${{ github.event.pull_request.head.sha }}
3535
36- - name : Parse delivery file
36+ - name : Debug delivery file
37+ run : |
38+ echo "Checking file: ${{ matrix.filename }}"
39+ echo "File path: ${{ github.workspace }}/${{ matrix.filename }}"
40+ echo "File exists: $(test -f "${{ github.workspace }}/${{ matrix.filename }}" && echo 'YES' || echo 'NO')"
41+ echo ""
42+ echo "Content around 'Application Document':"
43+ grep -n -A2 -B2 -i "application document" "${{ github.workspace }}/${{ matrix.filename }}" || echo "Pattern not found"
44+
45+ - name : Extract application document (Fixed regex)
3746 id : parse-delivery
38- uses : w3f/parse-milestone-delivery-action@master
39- with :
40- path : " ${{ github.workspace }}/${{ matrix.filename }}"
47+ run : |
48+ file_path="${{ github.workspace }}/${{ matrix.filename }}"
49+
50+ # Try multiple patterns to extract application document
51+ app_doc=""
52+
53+ # Pattern 1: With bullet point and bold formatting (matches your JS parser)
54+ app_doc=$(grep -oP "\*\s*\*\*Application Document:\*\*\s*\K[^\s\n]+" "$file_path" 2>/dev/null | head -1 || echo "")
55+
56+ # Pattern 2: Without bullet point (fallback)
57+ if [ -z "$app_doc" ]; then
58+ app_doc=$(grep -oP "\*\*Application Document:\*\*\s*\K[^\s\n]+" "$file_path" 2>/dev/null | head -1 || echo "")
59+ fi
60+
61+ # Pattern 3: Simple applications/*.md pattern anywhere in file
62+ if [ -z "$app_doc" ]; then
63+ app_doc=$(grep -o "applications/[^[:space:]]*\.md" "$file_path" 2>/dev/null | head -1 || echo "")
64+ fi
65+
66+ # Pattern 4: More flexible regex for applications/ files
67+ if [ -z "$app_doc" ]; then
68+ app_doc=$(grep -E "applications/[a-zA-Z0-9_-]+\.md" "$file_path" 2>/dev/null | head -1 || echo "")
69+ fi
70+
71+ if [ -z "$app_doc" ]; then
72+ echo "Error: Could not extract application document from $file_path"
73+ echo "File content for debugging:"
74+ head -20 "$file_path"
75+ exit 1
76+ fi
77+
78+ echo "application_document=$app_doc" >> $GITHUB_OUTPUT
79+ echo "Found application document: $app_doc"
4180
4281 - name : Find PR author in application authors
43- uses : actions/github-script@v5
82+ uses : actions/github-script@v7
4483 env :
4584 pr_author : ${{ github.event.pull_request.user.login }}
4685 with :
4786 script : |
87+ try {
88+ console.log(`Checking commits for: ${{ steps.parse-delivery.outputs.application_document }}`);
89+ console.log(`PR Author: ${process.env.pr_author}`);
90+
4891 const app_commits = await github.rest.repos.listCommits({
4992 owner: 'Polkadot-Fast-Grants',
5093 repo: 'apply',
51- path: 'applications/ ${{ steps.parse-delivery.outputs.application_document }}'
94+ path: '${{ steps.parse-delivery.outputs.application_document }}'
5295 });
5396
54- const app_authors = app_commits.data.map(c => c.author.login);
55- console.log(app_authors);
56-
97+ if (app_commits.data.length === 0) {
98+ core.setFailed(`No commits found for application file: ${{ steps.parse-delivery.outputs.application_document }}`);
99+ return;
100+ }
101+
102+ const app_authors = app_commits.data
103+ .map(c => c.author?.login)
104+ .filter(author => author != null && author !== undefined);
105+
106+ console.log(`Application authors found: ${app_authors.join(', ')}`);
107+
108+ if (app_authors.length === 0) {
109+ core.setFailed('No valid authors found in application commits');
110+ return;
111+ }
57112
58113 if (!app_authors.includes(process.env.pr_author)) {
59- core.setFailed('PR author does not match any application author.');
114+ core.setFailed(`PR author '${process.env.pr_author}' does not match any application author. Valid authors: ${app_authors.join(', ')}`);
115+ } else {
116+ console.log('Author check passed! PR author matches application author.');
60117 }
118+
119+ } catch (error) {
120+ console.error('Error details:', error);
121+ core.setFailed(`Error checking application authors: ${error.message}`);
122+ }
0 commit comments