Update GH token #4
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
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: '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" > my_org_PRs.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 | |
# 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 | |
timestamp=$(date -u) | |
git commit -m "Latest data: ${timestamp}" || exit 0 | |
git push --force origin HEAD:refs/heads/n2020h-issues-to-csv | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |