Skip to content

Papi Simulator - 2 Milestone #14

Papi Simulator - 2 Milestone

Papi Simulator - 2 Milestone #14

Workflow file for this run

name: Check Author
on:
pull_request_target:
types: [opened, synchronize]
jobs:
get-delivery-files:
runs-on: ubuntu-latest
outputs:
filenames: ${{ steps.files.outputs.added }}
steps:
- name: Get filenames of any deliveries being added
id: files
uses: Ana06/get-changed-files@v2.3.0
with:
format: 'json'
filter: |
deliveries/*.md
maintenance_deliveries/*.md
check_author:
runs-on: ubuntu-latest
needs: get-delivery-files
if: needs.get-delivery-files.outputs.filenames != '[]'
strategy:
fail-fast: false
matrix:
filename: ${{ fromJson(needs.get-delivery-files.outputs.filenames) }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Parse delivery file using custom script
id: parse-delivery
run: |
node .github/scripts/parse-fast-grants-delivery.js "${{ github.workspace }}/${{ matrix.filename }}"
- name: Find PR author in application authors
uses: actions/github-script@v7
env:
pr_author: ${{ github.event.pull_request.user.login }}
with:
script: |
try {
console.log(`Checking commits for: ${{ steps.parse-delivery.outputs.application_document }}`);
console.log(`PR Author: ${process.env.pr_author}`);
const app_commits = await github.rest.repos.listCommits({
owner: 'Polkadot-Fast-Grants',
repo: 'apply',
path: '${{ steps.parse-delivery.outputs.application_document }}'
});
if (app_commits.data.length === 0) {
core.setFailed(`No commits found for application file: ${{ steps.parse-delivery.outputs.application_document }}`);
return;
}
const app_authors = app_commits.data
.map(c => c.author?.login)
.filter(author => author != null && author !== undefined);
console.log(`Application authors found: ${app_authors.join(', ')}`);
if (app_authors.length === 0) {
core.setFailed('No valid authors found in application commits');
return;
}
if (!app_authors.includes(process.env.pr_author)) {
core.setFailed(`PR author '${process.env.pr_author}' does not match any application author. Valid authors: ${app_authors.join(', ')}`);
} else {
console.log('Author check passed! PR author matches application author.');
}
} catch (error) {
console.error('Error details:', error);
core.setFailed(`Error checking application authors: ${error.message}`);
}