weekly_update_changelog.yml 2.0 KB

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