Skip to content

Commit

Permalink
Add generate csv.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
n2020h authored Feb 13, 2024
1 parent ea64d92 commit 26789e4
Showing 1 changed file with 49 additions and 17 deletions.
66 changes: 49 additions & 17 deletions .github/workflows/issues-to-csv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,65 @@ name: List Issues and Output as CSV
on:
pull_request:
issues:
types: [opened, transferred, assigned]
type: [opened]


jobs:
# Adds newly created issues onto project board in the default column 'New Issue Approval'
# unless overridden when issue has "LA website bot" in title, then 'Questions / In Review'
list-issues:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'issues' && github.event.action == 'opened' }}
# env:
# COLUMN_NAME: ${{ contains(github.event.issue.title, 'Hack for LA website bot') && 'Questions / In Review' || 'New Issue Approval' }}
steps:
- name: List Issues for Repository
id: list_issues
# id: list_issues
uses: alex-page/github-project-automation-plus@v0.9.0
with:
project: Volunteer Dashboard
column: ${{ env.COLUMN_NAME }}
repo-token: ${{ secrets.HACKFORLA_BOT_PA_TOKEN }}

# Checkout the repo to access the generate_csv.py script
- name: Checkout repository
uses: actions/checkout@v3

- name: Generate issues CSV
run: |
echo "issue_id,issue_title,issue_state" > issues.csv
PAGE=1
while :; do
RESPONSE=$(gh api repos/$ORGANIZATION/website/issues -f state=all -f per_page=100 -f page=$PAGE)
echo "$RESPONSE" | jq -r '.[] | "\(.id),\(.title),\(.state)"' >> issues.csv
COUNT=$(echo "$RESPONSE" | jq length)
if [ "$COUNT" -lt 100 ]; then
break
fi
((PAGE++))
done
echo "Issue Number,Title,Labels,Projects" > issues.csv
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues?state=all&per_page=100" | \
jq -r '.[] | select(.pull_request == null) | [.number, .title, (.labels | map(.name) | join(",")), (.projectCards | map(.project_url) | join(","))] | @csv' >> issues.csv
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORGANIZATION: 'hackforla'

- name: Upload CSV as Artifact
uses: actions/upload-artifact@v2
- name: Upload CSV as artifact
uses: actions/upload-artifact@v3
with:
name: issues.csv
name: issues-csv
path: issues.csv

# # Setup Python environment
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: '3.8'

# # Install Python dependencies (if any)
# - name: Install dependencies
# run: pip install -r requirements.txt

# # Run the script to generate the CSV file
# - name: Generate CSV of issues
# run: python generate_csv.py
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# OUTPUT_FILENAME: issues.csv

# # Upload issues.csv as an artifact
# - name: Upload CSV as artifact
# uses: actions/upload-artifact@v3
# with:
# name: issues-csv
# path: issues.csv

0 comments on commit 26789e4

Please sign in to comment.