|
| 1 | +name: Weekly repo metrics |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + schedule: |
| 5 | + - cron: '0 9 * * MON' |
| 6 | + |
| 7 | +permissions: |
| 8 | + issues: write |
| 9 | + pull-requests: read |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + # this workflow will always fail in forks; bail if this isn't running in the upstream |
| 14 | + if: github.repository == 'aws/aws-cdk' |
| 15 | + name: metrics |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Get dates for last week |
| 20 | + shell: bash |
| 21 | + run: | |
| 22 | + # Calculate the date of the previous Monday |
| 23 | + PREVIOUS_MONDAY=$(date -d "7 days ago" "+%Y-%m-%d") |
| 24 | +
|
| 25 | + # Calculate the date of the current Sunday |
| 26 | + CURRENT_SUNDAY=$(date -d "1 day ago" "+%Y-%m-%d") |
| 27 | +
|
| 28 | + # Set an environment variable with the date range |
| 29 | + echo "$PREVIOUS_MONDAY..$CURRENT_SUNDAY" |
| 30 | + echo "last_week=$PREVIOUS_MONDAY..$CURRENT_SUNDAY" >> "$GITHUB_ENV" |
| 31 | +
|
| 32 | + - name: Report on issues |
| 33 | + uses: github/issue-metrics@v2 |
| 34 | + env: |
| 35 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + SEARCH_QUERY: 'repo:aws/aws-cdk is:issue created:${{ env.last_week }} -reason:"not planned"' |
| 37 | + |
| 38 | + - name: Create report for issues |
| 39 | + uses: peter-evans/create-issue-from-file@v5 |
| 40 | + with: |
| 41 | + title: Weekly issue metrics report |
| 42 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + content-filepath: ./issue_metrics.md |
| 44 | + assignees: paulhcsun |
| 45 | + |
| 46 | + - name: Report on PRs |
| 47 | + uses: github/issue-metrics@v2 |
| 48 | + env: |
| 49 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + SEARCH_QUERY: 'repo:aws/aws-cdk is:pr created:${{ env.last_week }} -is:draft' |
| 51 | + |
| 52 | + - name: Create report for PRs |
| 53 | + uses: peter-evans/create-issue-from-file@v5 |
| 54 | + with: |
| 55 | + title: Weekly PR metrics report |
| 56 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + content-filepath: ./issue_metrics.md |
| 58 | + assignees: paulhcsun |
0 commit comments