sync-fork.yml 1.2 KB

123456789101112131415161718192021222324252627282930
  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. - name: Synchronize fork
  15. run: gh repo sync $REPOSITORY -b $BRANCH_NAME
  16. env:
  17. GITHUB_TOKEN: ${{ secrets.ISSRC_BUILD_ENV_SYNC_TOKEN }}
  18. REPOSITORY: ${{ github.repository }}
  19. BRANCH_NAME: ${{ github.ref_name }}
  20. - name: Copilot review request
  21. run: |
  22. PR_NUMBER=$(gh pr list --repo "$REPOSITORY" --state open --base "$PR_BASE" --head "$BRANCH_NAME" --json number --jq '.[0].number')
  23. if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then
  24. gh api --method POST /repos/$REPOSITORY/pulls/$PR_NUMBER/requested_reviewers -f "reviewers[]=copilot-pull-request-reviewer[bot]"
  25. fi
  26. env:
  27. GITHUB_TOKEN: ${{ secrets.ISSRC_BUILD_ENV_SYNC_TOKEN }}
  28. REPOSITORY: ${{ github.repository }}
  29. BRANCH_NAME: ${{ github.ref_name }}
  30. PR_BASE: copilot-review