auto-sync.yml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. name: AutoSync
  2. on:
  3. push:
  4. branches:
  5. - 'master'
  6. jobs:
  7. Create-PR:
  8. runs-on: ubuntu-20.04
  9. steps:
  10. - uses: actions/checkout@v3
  11. with:
  12. token: ${{ secrets.GHP_TOKEN }}
  13. repository: ${{ secrets.DST_REPO }}
  14. ref: ${{ secrets.DST_REPO_BRANCH }}
  15. path: dst-repo
  16. - name: Get PR data
  17. run: |
  18. echo "REPO=${{ github.repository }}" >> $GITHUB_ENV
  19. echo "COMMIT_SHA=${{ github.event.after }}" >> $GITHUB_ENV
  20. echo "SHORT_SHA=$(echo ${{ github.event.after }} | cut -c1-8)" >> $GITHUB_ENV
  21. echo "USERNAME=${{ github.event.head_commit.author.username }}" >> $GITHUB_ENV
  22. echo "USER_EMAIL=${{ github.event.head_commit.author.username }}@users.noreply.github.com" >> $GITHUB_ENV
  23. echo "PR_NAME=$(echo '${{ github.event.head_commit.message }}' | head -1 | sed 's|#|${{ github.repository }}#|g')" >> $GITHUB_ENV
  24. - name: Cherry pick commit
  25. continue-on-error: true
  26. run: |
  27. cd dst-repo
  28. git config --global user.name ${{ env.USERNAME }}
  29. git config --global user.email ${{ env.USER_EMAIL }}
  30. git fetch https://github.com/${{ env.REPO }}.git master
  31. git cherry-pick FETCH_HEAD --strategy-option octopus
  32. - name: Add modified files
  33. run: |
  34. cd dst-repo
  35. git add .
  36. - name: Create Pull Request
  37. uses: peter-evans/create-pull-request@v4
  38. with:
  39. path: dst-repo
  40. token: ${{ secrets.GHP_TOKEN }}
  41. body: |
  42. **Auto-generated PR**
  43. Repo - [${{ env.REPO }}](https://github.com/${{ env.REPO }})
  44. PR name - ${{ env.PR_NAME }}
  45. Commit - ${{ env.REPO }}@${{ env.COMMIT_SHA }}
  46. Author - @${{ env.USERNAME }}
  47. branch: AutoPR/${{ env.SHORT_SHA }}
  48. assignees: ${{ env.USERNAME }}
  49. title: ${{ env.PR_NAME }}
  50. labels: AutoPR
  51. author: ${{ env.USERNAME }} <${{ env.USER_EMAIL }}>