mirror of
https://github.com/tuna/mirror-web.git
synced 2025-12-25 20:32:46 +00:00
46 lines
1.7 KiB
YAML
46 lines
1.7 KiB
YAML
name: 'Sync mirrorz-help-ng'
|
|
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: |
|
|
transpiled_dir="help/_posts/mirrorz-help-ng-transpiled"
|
|
track_branch="transpiled"
|
|
if [ -n "$NEW_COMMIT" ]; then
|
|
git -C "$transpiled_dir" fetch origin "+$NEW_COMMIT:refs/remotes/origin/incoming" --depth=1
|
|
git -C "$transpiled_dir" checkout --force "$NEW_COMMIT"
|
|
else
|
|
git -C "$transpiled_dir" fetch origin "+refs/heads/${track_branch}:refs/remotes/origin/${track_branch}" --depth=1
|
|
git -C "$transpiled_dir" checkout --force "origin/${track_branch}"
|
|
NEW_COMMIT=$(git -C "$transpiled_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 tuna/mirrorz-help-ng@$NEW_COMMIT" > /tmp/pr_msg
|
|
- name: Create Pull Request
|
|
uses: peter-evans/create-pull-request@v6
|
|
with:
|
|
title: 'helpz: sync mirrorz-help-ng@${{ env.NEW_COMMIT_SHORT }}'
|
|
commit-message: 'helpz: sync tuna/mirrorz-help-ng@${{ 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
|