|
| 1 | +--- |
| 2 | +name: stale repo identifier |
| 3 | + |
| 4 | +"on": |
| 5 | + workflow_dispatch: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + - get_stale # for testing only - remove! |
| 10 | + schedule: |
| 11 | + - cron: "3 2 1 * *" |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + issues: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + name: Stale repo identifier |
| 20 | + runs-on: ubuntu-latest |
| 21 | + strategy: |
| 22 | + matrix: |
| 23 | + days: [335, 365] |
| 24 | + |
| 25 | + permissions: |
| 26 | + contents: read |
| 27 | + |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Run stale_repos tool |
| 32 | + |
| 33 | + env: |
| 34 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + ORGANIZATION: SovereignCloudStack |
| 36 | + INACTIVE_DAYS: ${{ matrix.days }} |
| 37 | + ACTIVITY_METHOD: "pushed" |
| 38 | + ADDITIONAL_METRICS: "release,pr" |
| 39 | + |
| 40 | + - name: Rename report file |
| 41 | + run: mv stale_repos.md stale_repos_${{ matrix.days }}.md |
| 42 | + |
| 43 | + - name: Upload stale report artifact |
| 44 | + uses: actions/upload-artifact@v4 |
| 45 | + with: |
| 46 | + name: stale_repos_report_${{ matrix.days }} |
| 47 | + path: stale_repos_${{ matrix.days }}.md |
| 48 | + |
| 49 | + create-issue: |
| 50 | + name: Create or update stale repo issue |
| 51 | + runs-on: ubuntu-latest |
| 52 | + needs: build # Runs after all matrix jobs finish |
| 53 | + |
| 54 | + permissions: |
| 55 | + issues: write |
| 56 | + |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v4 |
| 59 | + |
| 60 | + - name: Download all stale report artifacts |
| 61 | + uses: actions/download-artifact@v4 |
| 62 | + with: |
| 63 | + path: stale_reports |
| 64 | + |
| 65 | + - name: Merge reports |
| 66 | + run: | |
| 67 | + echo "# Stale Repository Report" > final_stale_repos.md |
| 68 | + for file in stale_reports/**/stale_repos_*.md; do |
| 69 | + cat "$file" >> final_stale_repos.md |
| 70 | + echo "" >> final_stale_repos.md |
| 71 | + done |
| 72 | +
|
| 73 | + - name: Check for the stale report issue |
| 74 | + run: | |
| 75 | + ISSUE_NUMBER=$(gh search issues "Stale repository report" --match title --json number --jq ".[0].number") |
| 76 | + echo "issue_number=$ISSUE_NUMBER" >> "$GITHUB_ENV" |
| 77 | + env: |
| 78 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + |
| 80 | + - name: Create or update issue |
| 81 | + uses: peter-evans/create-issue-from-file@v5 |
| 82 | + with: |
| 83 | + issue-number: ${{ env.issue_number }} |
| 84 | + title: Stale repository report |
| 85 | + content-filepath: ./final_stale_repos.md |
| 86 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments