generate projects data #9
This file contains hidden or 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: generate projects data | |
| on: | |
| # schedule: | |
| # - cron: '0 */6 * * *' # every 6 hours | |
| workflow_dispatch: | |
| env: | |
| PROJECT_ID: 70 # <== customize this per team/project | |
| SNAPSHOT_PATH: ./snapshots # <== customize where you want .json files to live | |
| SPRINT_NAME: Sprint-44 # <== customize this to your current sprint name | |
| GH_TOKEN: ${{ secrets.GH_PROJECTS_PAT}} # <== ensure this secret is set in your repo | |
| jobs: | |
| example: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Use GitHub CLI | |
| run: | | |
| gh auth status | |
| gh issue list --repo fleetdm/fleet --limit 5 | |
| - name: Download projects data | |
| run: | | |
| mkdir -p .tmp | |
| echo "Fetch all items (unfiltered)..." | |
| gh project item-list ${{ env.PROJECT_ID }} --owner fleetdm --limit 1000 --format json > .tmp/items.json | |
| - name: Setup Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.24' | |
| - name: Generate projects data | |
| run: | | |
| go mod tidy | |
| go run ./cmd/snapshots.go | |
| - name: Commit and push changes | |
| run: | | |
| git config --local user.name "GitHub Actions" | |
| git config --local user.email "actions@github.com" | |
| git add ${{ env.SNAPSHOT_PATH }} | |
| if git diff --cached --quiet; then | |
| echo "No changes to commit." | |
| exit 0 | |
| else | |
| git commit -m "Update projects data for ${{ env.SPRINT_NAME }}" | |
| git push origin main | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |