PR Tracker #27
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: PR Tracker | |
on: | |
schedule: | |
# Runs daily at 9:00 AM UTC | |
- cron: '0 9 * * *' | |
workflow_dispatch: # Allows manual triggering (optional) | |
jobs: | |
track_prs: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
# Fetch all history so that git push can find the latest commits | |
fetch-depth: 0 | |
# Step 2: Install Dependencies (gh CLI and jq) | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y jq | |
# Install GitHub CLI (gh) | |
type -p curl >/dev/null || (sudo apt-get install -y curl) | |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | \ | |
sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg | |
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg | |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | \ | |
sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null | |
sudo apt-get update | |
sudo apt-get install -y gh | |
# Step 3: Authenticate GitHub CLI with Fine-Grained PAT | |
- name: Authenticate gh CLI | |
env: | |
GITHUB_PAT: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
run: | | |
echo "${GITHUB_PAT}" | gh auth login --with-token | |
# Step 4: Make the script executable (if not already) | |
- name: Make Script Executable | |
run: chmod +x scripts/pr_tracker.sh | |
# Step 5: Run the PR Tracker Script | |
- name: Run PR Tracker Script | |
run: ./scripts/pr_tracker.sh | |
# Step 6: Configure Git for Commit | |
- name: Configure Git | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
# Step 7: Commit CSV Files if There Are Changes | |
- name: Commit CSV Reports | |
run: | | |
# Navigate to the directory where CSVs are stored | |
# For example, if you store them in /reports/, adjust accordingly | |
# Here, assuming they're in the root directory | |
# Check for changes in the CSV files | |
git add pr.csv | |
if git diff --cached --quiet; then | |
echo "No changes to commit." | |
else | |
# Commit changes with a timestamp | |
git commit -m "Update PR reports - $(date +"%Y-%m-%d %H:%M:%S")" | |
# Push changes | |
git push origin HEAD:${{ github.ref }} | |
fi |