sync-fork.yml 1.1 KB

12345678910111213141516171819202122232425262728
  1. name: sync-fork
  2. on:
  3. schedule:
  4. - cron: '0 0 * * *'
  5. workflow_dispatch:
  6. jobs:
  7. sync:
  8. # Only set the topic `has-issrc-build-env-sync-token` if the secret is available
  9. if: contains(github.event.repository.topics, 'has-issrc-build-env-sync-token')
  10. runs-on: ubuntu-latest
  11. permissions:
  12. contents: write
  13. steps:
  14. - run: gh repo sync $REPOSITORY -b $BRANCH_NAME
  15. env:
  16. GITHUB_TOKEN: ${{ secrets.ISSRC_BUILD_ENV_SYNC_TOKEN }}
  17. REPOSITORY: ${{ github.repository }}
  18. BRANCH_NAME: ${{ github.ref_name }}
  19. - run: |
  20. PR_NUMBER=$(gh pr list --repo "$REPOSITORY" --state open --base "$PR_BASE" --head "$BRANCH_NAME" --json number --jq '.[0].number')
  21. if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then
  22. gh api --method POST /repos/$REPOSITORY/pulls/$PR_NUMBER/requested_reviewers -f "reviewers[]=copilot-pull-request-reviewer[bot]"
  23. fi
  24. env:
  25. GITHUB_TOKEN: ${{ secrets.ISSRC_BUILD_ENV_SYNC_TOKEN }}
  26. REPOSITORY: ${{ github.repository }}
  27. BRANCH_NAME: ${{ github.ref_name }}
  28. PR_BASE: copilot-review