|
| 1 | +name: GitHub Metrics |
| 2 | + |
| 3 | +# on: |
| 4 | +# workflow_dispatch: |
| 5 | +# schedule: |
| 6 | +# - cron: '3 2 1 * *' |
| 7 | +on: [pull_request] |
| 8 | + |
| 9 | +jobs: |
| 10 | + get_dates: |
| 11 | + name: Get Dates |
| 12 | + runs-on: ubuntu-latest |
| 13 | + outputs: |
| 14 | + report_month: ${{ steps.get_dates.outputs.report_month }} |
| 15 | + last_month: ${{ steps.get_dates.outputs.last_month }} |
| 16 | + steps: |
| 17 | + - id: get_dates |
| 18 | + name: Get dates for last month |
| 19 | + shell: bash |
| 20 | + run: | |
| 21 | + # Get the current date |
| 22 | + current_date=$(date +'%Y-%m-%d') |
| 23 | + |
| 24 | + # Calculate the previous month |
| 25 | + previous_date=$(date -d "$current_date -1 month" +'%Y-%m-%d') |
| 26 | + |
| 27 | + # Put the report month and year in the environment |
| 28 | + echo report_month="$(date -d "$previous_date" +'%B') $(date -d "$previous_date" +'%Y')" >> "$GITHUB_OUTPUT" |
| 29 | + |
| 30 | + # Extract the year and month from the previous date |
| 31 | + previous_year=$(date -d "$previous_date" +'%Y') |
| 32 | + previous_month=$(date -d "$previous_date" +'%m') |
| 33 | + |
| 34 | + # Calculate the first day of the previous month |
| 35 | + first_day=$(date -d "$previous_year-$previous_month-01" +'%Y-%m-%d') |
| 36 | + |
| 37 | + # Calculate the last day of the previous month |
| 38 | + last_day=$(date -d "$first_day +1 month -1 day" +'%Y-%m-%d') |
| 39 | + |
| 40 | + echo "$first_day..$last_day" |
| 41 | + echo "last_month=$first_day..$last_day" >> "$GITHUB_OUTPUT" |
| 42 | + |
| 43 | + # Issues |
| 44 | + issues_opened: |
| 45 | + name: Issues Opened |
| 46 | + runs-on: ubuntu-latest |
| 47 | + needs: get_dates |
| 48 | + steps: |
| 49 | + - name: Run issue-metrics tool for issues opened last month |
| 50 | + uses: github/issue-metrics@v2 |
| 51 | + env: |
| 52 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 53 | + SEARCH_QUERY: 'org:appwrite org:open-runtimes org:utopia-php is:issue created:${{ needs.get_dates.outputs.last_month }}' |
| 54 | + HIDE_TIME_TO_ANSWER: true |
| 55 | + |
| 56 | + - id: create_issue |
| 57 | + name: Create issue |
| 58 | + uses: peter-evans/create-issue-from-file@v4 |
| 59 | + with: |
| 60 | + title: Issues Opened in ${{ needs.get_dates.outputs.report_month }} |
| 61 | + content-filepath: ./issue_metrics.md |
| 62 | + |
| 63 | + - name: Attach JSON |
| 64 | + uses: peter-evans/create-or-update-comment@v3 |
| 65 | + with: |
| 66 | + issue-number: ${{ steps.create_issue.outputs.issue-number }} |
| 67 | + body-path: ./issue_metrics.json |
| 68 | + |
| 69 | + issues_closed: |
| 70 | + name: Issues Closed |
| 71 | + runs-on: ubuntu-latest |
| 72 | + needs: get_dates |
| 73 | + steps: |
| 74 | + - name: Run issue-metrics tool for issues closed last month |
| 75 | + uses: github/issue-metrics@v2 |
| 76 | + env: |
| 77 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 78 | + SEARCH_QUERY: 'org:appwrite org:open-runtimes org:utopia-php is:issue closed:${{ needs.get_dates.outputs.last_month }}' |
| 79 | + HIDE_TIME_TO_ANSWER: true |
| 80 | + |
| 81 | + - id: create_issue |
| 82 | + name: Create issue |
| 83 | + uses: peter-evans/create-issue-from-file@v4 |
| 84 | + with: |
| 85 | + title: Issues Closed in ${{ needs.get_dates.outputs.report_month }} |
| 86 | + content-filepath: ./issue_metrics.md |
| 87 | + |
| 88 | + - id: comment_issue |
| 89 | + name: Prepare JSON comment |
| 90 | + uses: peter-evans/create-or-update-comment@v3 |
| 91 | + with: |
| 92 | + issue-number: ${{ steps.create_issue.outputs.issue-number }} |
| 93 | + body: "```json" |
| 94 | + |
| 95 | + - name: Attach JSON |
| 96 | + uses: peter-evans/create-or-update-comment@v3 |
| 97 | + with: |
| 98 | + comment-id: ${{ steps.comment_issue.outputs.comment-id }} |
| 99 | + body-path: ./issue_metrics.json |
| 100 | + edit-mode: append |
| 101 | + |
| 102 | + - name: Finish JSON comment |
| 103 | + uses: peter-evans/create-or-update-comment@v3 |
| 104 | + with: |
| 105 | + comment-id: ${{ steps.comment_issue.outputs.comment-id }} |
| 106 | + body: "```" |
| 107 | + edit-mode: append |
| 108 | + |
| 109 | + # PRs |
| 110 | + prs_opened: |
| 111 | + name: PRs Opened |
| 112 | + runs-on: ubuntu-latest |
| 113 | + needs: get_dates |
| 114 | + steps: |
| 115 | + - name: Run issue-metrics tool for PRs opened last month |
| 116 | + uses: github/issue-metrics@v2 |
| 117 | + env: |
| 118 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 119 | + SEARCH_QUERY: 'org:appwrite org:open-runtimes org:utopia-php is:pull-request created:${{ needs.get_dates.outputs.last_month }}' |
| 120 | + HIDE_TIME_TO_ANSWER: true |
| 121 | + |
| 122 | + - id: create_issue |
| 123 | + name: Create issue |
| 124 | + uses: peter-evans/create-issue-from-file@v4 |
| 125 | + with: |
| 126 | + title: PRs Opened in ${{ needs.get_dates.outputs.report_month }} |
| 127 | + content-filepath: ./issue_metrics.md |
| 128 | + |
| 129 | + - id: comment_issue |
| 130 | + name: Prepare JSON comment |
| 131 | + uses: peter-evans/create-or-update-comment@v3 |
| 132 | + with: |
| 133 | + issue-number: ${{ steps.create_issue.outputs.issue-number }} |
| 134 | + body: "```json" |
| 135 | + |
| 136 | + - name: Attach JSON |
| 137 | + uses: peter-evans/create-or-update-comment@v3 |
| 138 | + with: |
| 139 | + comment-id: ${{ steps.comment_issue.outputs.comment-id }} |
| 140 | + body-path: ./issue_metrics.json |
| 141 | + edit-mode: append |
| 142 | + |
| 143 | + - name: Finish JSON comment |
| 144 | + uses: peter-evans/create-or-update-comment@v3 |
| 145 | + with: |
| 146 | + comment-id: ${{ steps.comment_issue.outputs.comment-id }} |
| 147 | + body: "```" |
| 148 | + edit-mode: append |
| 149 | + |
| 150 | + prs_closed: |
| 151 | + name: PRs Closed |
| 152 | + runs-on: ubuntu-latest |
| 153 | + needs: get_dates |
| 154 | + steps: |
| 155 | + - name: Run issue-metrics tool for PRs closed last month |
| 156 | + uses: github/issue-metrics@v2 |
| 157 | + env: |
| 158 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 159 | + SEARCH_QUERY: 'org:appwrite org:open-runtimes org:utopia-php is:pull-request closed:${{ needs.get_dates.outputs.last_month }}' |
| 160 | + HIDE_TIME_TO_ANSWER: true |
| 161 | + |
| 162 | + - id: create_issue |
| 163 | + name: Create issue |
| 164 | + uses: peter-evans/create-issue-from-file@v4 |
| 165 | + with: |
| 166 | + title: PRs Closed in ${{ needs.get_dates.outputs.report_month }} |
| 167 | + content-filepath: ./issue_metrics.md |
| 168 | + |
| 169 | + - id: comment_issue |
| 170 | + name: Prepare JSON comment |
| 171 | + uses: peter-evans/create-or-update-comment@v3 |
| 172 | + with: |
| 173 | + issue-number: ${{ steps.create_issue.outputs.issue-number }} |
| 174 | + body: "```json" |
| 175 | + |
| 176 | + - name: Attach JSON |
| 177 | + uses: peter-evans/create-or-update-comment@v3 |
| 178 | + with: |
| 179 | + comment-id: ${{ steps.comment_issue.outputs.comment-id }} |
| 180 | + body-path: ./issue_metrics.json |
| 181 | + edit-mode: append |
| 182 | + |
| 183 | + - name: Finish JSON comment |
| 184 | + uses: peter-evans/create-or-update-comment@v3 |
| 185 | + with: |
| 186 | + comment-id: ${{ steps.comment_issue.outputs.comment-id }} |
| 187 | + body: "```" |
| 188 | + edit-mode: append |
| 189 | + |
| 190 | + # Discussions |
| 191 | + discussions_opened: |
| 192 | + name: Discussions Opened |
| 193 | + runs-on: ubuntu-latest |
| 194 | + needs: get_dates |
| 195 | + steps: |
| 196 | + - name: Run issue-metrics tool for discussions opened last month |
| 197 | + uses: github/issue-metrics@v2 |
| 198 | + env: |
| 199 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 200 | + SEARCH_QUERY: 'org:appwrite org:open-runtimes org:utopia-php type:discussions created:${{ needs.get_dates.outputs.last_month }}' |
| 201 | + |
| 202 | + - id: create_issue |
| 203 | + name: Create issue |
| 204 | + uses: peter-evans/create-issue-from-file@v4 |
| 205 | + with: |
| 206 | + title: Discussions Opened in ${{ needs.get_dates.outputs.report_month }} |
| 207 | + content-filepath: ./issue_metrics.md |
| 208 | + |
| 209 | + - id: comment_issue |
| 210 | + name: Prepare JSON comment |
| 211 | + uses: peter-evans/create-or-update-comment@v3 |
| 212 | + with: |
| 213 | + issue-number: ${{ steps.create_issue.outputs.issue-number }} |
| 214 | + body: "```json" |
| 215 | + |
| 216 | + - name: Attach JSON |
| 217 | + uses: peter-evans/create-or-update-comment@v3 |
| 218 | + with: |
| 219 | + comment-id: ${{ steps.comment_issue.outputs.comment-id }} |
| 220 | + body-path: ./issue_metrics.json |
| 221 | + edit-mode: append |
| 222 | + |
| 223 | + - name: Finish JSON comment |
| 224 | + uses: peter-evans/create-or-update-comment@v3 |
| 225 | + with: |
| 226 | + comment-id: ${{ steps.comment_issue.outputs.comment-id }} |
| 227 | + body: "```" |
| 228 | + edit-mode: append |
| 229 | + |
| 230 | + discussions_closed: |
| 231 | + name: Discussions Closed |
| 232 | + runs-on: ubuntu-latest |
| 233 | + needs: get_dates |
| 234 | + steps: |
| 235 | + - name: Run issue-metrics tool for discussions closed last month |
| 236 | + uses: github/issue-metrics@v2 |
| 237 | + env: |
| 238 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 239 | + SEARCH_QUERY: 'org:appwrite org:open-runtimes org:utopia-php type:discussions closed:${{ needs.get_dates.outputs.last_month }}' |
| 240 | + |
| 241 | + - id: create_issue |
| 242 | + name: Create issue |
| 243 | + uses: peter-evans/create-issue-from-file@v4 |
| 244 | + with: |
| 245 | + title: Discussions Closed in ${{ needs.get_dates.outputs.report_month }} |
| 246 | + content-filepath: ./issue_metrics.md |
| 247 | + |
| 248 | + - id: comment_issue |
| 249 | + name: Prepare JSON comment |
| 250 | + uses: peter-evans/create-or-update-comment@v3 |
| 251 | + with: |
| 252 | + issue-number: ${{ steps.create_issue.outputs.issue-number }} |
| 253 | + body: "```json" |
| 254 | + |
| 255 | + - name: Attach JSON |
| 256 | + uses: peter-evans/create-or-update-comment@v3 |
| 257 | + with: |
| 258 | + comment-id: ${{ steps.comment_issue.outputs.comment-id }} |
| 259 | + body-path: ./issue_metrics.json |
| 260 | + edit-mode: append |
| 261 | + |
| 262 | + - name: Finish JSON comment |
| 263 | + uses: peter-evans/create-or-update-comment@v3 |
| 264 | + with: |
| 265 | + comment-id: ${{ steps.comment_issue.outputs.comment-id }} |
| 266 | + body: "```" |
| 267 | + edit-mode: append |
0 commit comments