weekly_update_changelog.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. name: Weekly Changelog Update
  2. on:
  3. schedule:
  4. - cron: '0 0 * * 0' # Every Sunday at 00:00
  5. branches:
  6. - main
  7. workflow_dispatch:
  8. env:
  9. GH_TOKEN: ${{ secrets.YDBOT_TOKEN }}
  10. jobs:
  11. gather-prs:
  12. runs-on: ubuntu-latest
  13. outputs:
  14. prs: ${{ steps.pr-list.outputs.prs }}
  15. steps:
  16. - name: Check out repository
  17. uses: actions/checkout@v4
  18. - name: Set up date range
  19. id: date-setup
  20. run: |
  21. LAST_WEEK_DATE=$(date -d "7 days ago" '+%Y-%m-%dT%H:%M:%SZ')
  22. echo "LAST_WEEK_DATE=$LAST_WEEK_DATE" >> $GITHUB_ENV
  23. - name: Get merged PRs
  24. id: pr-list
  25. run: |
  26. echo "::notice:: branch = ${GITHUB_REF_NAME}, date = $LAST_WEEK_DATE"
  27. PRS=$(gh pr list --state merged --json number,title,baseRefName,mergedAt --jq ".[] | select(.baseRefName == \"${GITHUB_REF_NAME}\" and .mergedAt >= \"$LAST_WEEK_DATE\") | {id: .number}" | jq -c -s ".")
  28. if [ -z "$PRS" ]; then
  29. PRS="[]"
  30. fi
  31. echo "$PRS" > prs.json
  32. echo "prs=$PRS" >> "$GITHUB_OUTPUT"
  33. - name: Debug PR list output
  34. run: |
  35. cat prs.json
  36. - name: Upload PRs JSON
  37. uses: actions/upload-artifact@v4
  38. with:
  39. name: prs-json
  40. path: prs.json
  41. update-changelog:
  42. needs: gather-prs
  43. runs-on: ubuntu-latest
  44. steps:
  45. - name: Check out the repository
  46. uses: actions/checkout@v4
  47. - name: Get current date
  48. id: get-date
  49. shell: bash
  50. run: echo "suffix=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
  51. - name: Update Changelog
  52. uses: ./.github/actions/update_changelog
  53. env:
  54. YDBOT_TOKEN: ${{ secrets.YDBOT_TOKEN }}
  55. with:
  56. pr_data: "${{ needs.gather-prs.outputs.prs }}"
  57. changelog_path: "./CHANGELOG.md" # RODO: Use the correct path to your CHANGELOG.md file
  58. base_branch: "${{ github.ref_name }}"
  59. suffix: "${{ env.suffix }}"