Add stale repos action #19
Workflow file for this run
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: stale repo identifier | |
| "on": | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| - get_stale # for testing only - remove! | |
| schedule: | |
| - cron: "3 2 1 * *" | |
| permissions: | |
| contents: read | |
| issues: write | |
| jobs: | |
| build: | |
| name: Stale repo identifier | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| days: [335, 365] | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run stale_repos tool | |
| uses: github/[email protected] | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| ORGANIZATION: SovereignCloudStack | |
| INACTIVE_DAYS: ${{ matrix.days }} | |
| ACTIVITY_METHOD: "pushed" | |
| ADDITIONAL_METRICS: "release,pr" | |
| - name: Rename report file | |
| run: mv stale_repos.md stale_repos_${{ matrix.days }}.md | |
| - name: Upload stale report artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: stale_repos_report_${{ matrix.days }} | |
| path: stale_repos_${{ matrix.days }}.md | |
| create-issue: | |
| name: Create or update stale repo issue | |
| runs-on: ubuntu-latest | |
| needs: build # Runs after all matrix jobs finish | |
| permissions: | |
| issues: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all stale report artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: stale_reports | |
| - name: Merge reports | |
| run: | | |
| echo "# Stale Repository Report" > final_stale_repos.md | |
| for file in stale_reports/**/stale_repos_*.md; do | |
| days=$(echo "$file" | grep -oE '[0-9]+') | |
| echo "## Report for $days days" >> final_stale_repos.md | |
| cat "$file" >> final_stale_repos.md | |
| echo "" >> final_stale_repos.md | |
| done | |
| - name: Check for the stale report issue | |
| run: | | |
| ISSUE_NUMBER=$(gh search issues "Stale repository report" --match title --json number --jq ".[0].number") | |
| echo "issue_number=$ISSUE_NUMBER" >> "$GITHUB_ENV" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create or update issue | |
| uses: peter-evans/create-issue-from-file@v5 | |
| with: | |
| issue-number: ${{ env.issue_number }} | |
| title: Stale repository report | |
| content-filepath: ./final_stale_repos.md | |
| token: ${{ secrets.GITHUB_TOKEN }} |