Sync mirrorz-docs #1063
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 'Sync mirrorz-docs' | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| new_commit: | |
| description: 'New commit hash' | |
| required: false | |
| type: string | |
| default: '' | |
| schedule: | |
| - cron: '33 22 * * *' # 06:33 AM in Asia/Shanghai (UTC+8) | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Sync submodule | |
| env: | |
| NEW_COMMIT: ${{ inputs.new_commit }} | |
| run: | | |
| zdoc_dir="_helpz/global" | |
| track_branch="main" | |
| if [ -n "$NEW_COMMIT" ]; then | |
| git -C "$zdoc_dir" fetch origin "+$NEW_COMMIT:refs/remotes/origin/incoming" --depth=1 | |
| git -C "$zdoc_dir" checkout --force "$NEW_COMMIT" | |
| else | |
| git -C "$zdoc_dir" fetch origin "+refs/heads/${track_branch}:refs/remotes/origin/${track_branch}" --depth=1 | |
| git -C "$zdoc_dir" checkout --force "origin/${track_branch}" | |
| NEW_COMMIT=$(git -C "$zdoc_dir" rev-parse HEAD) | |
| fi | |
| NEW_COMMIT_SHORT=$(echo "$NEW_COMMIT" | cut -c1-8) | |
| echo "NEW_COMMIT_SHORT=$NEW_COMMIT_SHORT" >> $GITHUB_ENV | |
| echo -n "Update submodules to @$NEW_COMMIT" > /tmp/pr_msg | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| title: 'helpz: sync mirrorz-org/mirrorz-docs@${{ env.NEW_COMMIT_SHORT }}' | |
| commit-message: 'helpz: sync mirrorz-org/mirrorz-docs@${{ env.NEW_COMMIT_SHORT }}' | |
| author: 'GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>' | |
| branch: helpz | |
| delete-branch: true | |
| body-path: /tmp/pr_msg |