Skip to content

Commit

Permalink
Refactor auto sync and create PR workflow (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
shibd authored Dec 18, 2023
1 parent 0d7ca12 commit f31a7b6
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions .github/workflows/create-sync-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,47 @@ jobs:
name: Create Docs Sync PR
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.SNBOT_GITHUB_TOKEN }}

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Sync docs
run: |
npm install
node sync.js
node auto-upgrade.js
- name: Create branch
id: create_branch
- name: Set commit message
id: set_commit_message
run: |
git config user.name "Streamnative Updater"
git config user.email "[email protected]"
git add -A .
# Your commands to make changes go here
DOCS_SYNC_DATE=$(date +"%Y%m%d")
DOCS_SYNC_BRANCH_NAME=sync/docs-sync-$DOCS_SYNC_DATE
echo "::set-output name=syncDate::$DOCS_SYNC_DATE"
git diff-index --quiet HEAD || (git commit -m "Docs sync $DOCS_SYNC_DATE" && git checkout -b $DOCS_SYNC_BRANCH_NAME && git push -q -f origin $DOCS_SYNC_BRANCH_NAME && echo "::set-output name=syncBranch::$DOCS_SYNC_BRANCH_NAME")
- name: Create new branch
run: |
git checkout -b sync/docs-sync-${{ steps.set_commit_message.outputs.syncDate }}
git push --set-upstream origin sync/docs-sync-${{ steps.set_commit_message.outputs.syncDate }}
- name: Commit and push if changed
id: commit_and_push
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_user_name: Streamnative Updater
commit_user_email: [email protected]
commit_message: Docs sync ${{ steps.set_commit_message.outputs.syncDate }}

- name: Create Pull Request
if: ${{ steps.create_branch.outputs.syncBranch != '' }}
uses: repo-sync/pull-request@v2
with:
pr_title: "[Docs Sync] ${{ steps.create_branch.outputs.syncDate }}"
source_branch: ${{ steps.create_branch.outputs.syncBranch }}
pr_title: "[Docs Sync] ${{ steps.set_commit_message.outputs.syncDate }}"
source_branch: sync/docs-sync-${{ steps.set_commit_message.outputs.syncDate }}
destination_branch: master
github_token: ${{ secrets.SNBOT_GITHUB_TOKEN }}
pr_body: |
[Docs Sync] ${{ steps.create_branch.outputs.syncDate }}
[Docs Sync] ${{ steps.set_commit_message.outputs.syncDate }}
${{ github.event.inputs.releaseDescription }}
pr_label: docs-sync

0 comments on commit f31a7b6

Please sign in to comment.