generated from hackforla/.github-hackforla-base-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: List Pull Requests and Output as CSV | ||
|
||
on: | ||
push: | ||
branches: | ||
- n2020h-issues-to-csv | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 0 * * *' # Runs daily at midnight | ||
pull_request: | ||
types: [opened, closed, reopened] | ||
branches: | ||
- n2020h-issues-to-csv | ||
|
||
jobs: | ||
list-pull-requests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout the repository to access any scripts or tools you might need | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
# Set up Node.js to use jq command | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
|
||
# Fetch pull requests from GitHub API and generate CSV | ||
- name: Fetch pull requests and generate CSV | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
# Fetch pull requests data and save it to pulls.json | ||
curl -H "Authorization: token $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/repos/${{ github.repository }}/pulls?state=all \ | ||
-o pulls.json | ||
# Use jq to parse pulls.json and generate my_org_PRs.csv | ||
jq -r '[.[] | { | ||
"PR Number": .number, | ||
"Title": .title, | ||
"Description": .body, | ||
"Author": .user.login, | ||
"State": .state, | ||
"Number of Commits": .commits, | ||
"Number of Files Changed": .changed_files, | ||
"Labels": (.labels | map(.name) | join(",")), | ||
"Assignees": (.assignees | map(.login) | join(",")), | ||
"Linked Issues": ([capture("#(?<number>\\d+)") | .number] | join(",")), | ||
"Reviewers": (.requested_reviewers | map(.login) | join(",")) | ||
}] | (first | keys_unsorted) as $keys | $keys, map([.[ $keys[] ]])[] | @csv' \ | ||
pulls.json > hackforla_pull_requests.csv | ||
# Commit and push the generated CSV to the repository | ||
- name: Commit and push CSV | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add my_org_PRs.csv | ||
git commit -m "Update pull requests CSV" | ||
git push | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |