Skip to content

Commit

Permalink
Update pull_requests_to_csv.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
n2020h authored Jul 23, 2024
1 parent a0d7f3d commit 2b17fbb
Showing 1 changed file with 23 additions and 26 deletions.
49 changes: 23 additions & 26 deletions .github/workflows/pull_requests_to_csv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Runs daily at midnight
pull_request:
types: [opened, closed, reopened]
branches:
- n2020h-issues-to-csv
# pull_request:
# types: [opened, closed, reopened]
# branches:
# - n2020h-issues-to-csv

jobs:
list-pull-requests:
Expand All @@ -22,38 +22,35 @@ jobs:
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: '20'
# - name: Set up Node.js
# uses: actions/setup-node@v3
# with:
# node-version: '20'

# Generate pull requests CSV
- name: Generate pull requests CSV
run: |
echo "PR Number,Title,Description,Author,State,Number of Commits,Number of Files Changed,Labels,Assignees,Linked Issues,Reviewers" > hackforla_pull_requests.csv
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls?state=all&per_page=100" | \
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": (.body | capture_all("#(?<number>\\d+)"; "g") | join(",")),
"Reviewers": (.requested_reviewers | map(.login) | join(","))
}] | (first | keys_unsorted) as $keys | $keys, map([.[ $keys[] ]])[] | @csv' >> hackforla_pull_requests.csv
run: |
echo "PR Number,Title,Description,Author,State,Number of Commits,Number of Files Changed,Labels,Assignees,Reviewers" > hackforla_PRs.csv
jq -r '.[] | [
.number,
.title,
.body,
.user.login,
.state,
.commits,
.changed_files,
(.labels | map(.name) | join(",")),
(.assignees | map(.login) | join(",")),
(.requested_reviewers | map(.login) | join(","))
] | @csv' pulls.json >> hackforla_PRs.csv
# Commit and push the generated CSV to the repository
- name: Commit and push CSV
run: |
git config user.name "Automated"
git config user.email "[email protected]"
git add -f hackforla_pull_requests.csv
git add -f hackforla_PRs.csv
timestamp=$(date -u)
git commit -m "Latest data: ${timestamp}" || exit 0
git push --force origin HEAD:refs/heads/n2020h-issues-to-csv
Expand Down

0 comments on commit 2b17fbb

Please sign in to comment.