This repository was archived by the owner on Mar 13, 2026. It is now read-only.
Sync Issue Templates #16
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 Issue Templates | |
| on: | |
| schedule: | |
| # 每周一凌晨0点(UTC时间)自动同步,相当于北京时间周一早上8点 | |
| - cron: '0 0 * * 1' | |
| workflow_dispatch: # 支持手动触发 | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - '.github/workflows/sync-templates.yml' # 当工作流文件本身更新时也触发 | |
| jobs: | |
| sync-templates: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # 需要写入权限来提交更改 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 # 获取所有历史记录,便于推送 | |
| - name: Set up Git | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Sync templates from issue-templates repository | |
| run: | | |
| # 克隆模板仓库到临时目录 | |
| git clone https://github.com/apocfly/issue-templates temp-templates | |
| # 确保目标目录存在 | |
| mkdir -p .github/ISSUE_TEMPLATE | |
| # 备份可能存在的自定义配置文件(如果有的话) | |
| if [ -f ".github/ISSUE_TEMPLATE/config.yml" ]; then | |
| cp .github/ISSUE_TEMPLATE/config.yml config-backup.yml | |
| fi | |
| # 复制所有模板文件(排除可能不需要的文件) | |
| cp -r temp-templates/.github/ISSUE_TEMPLATE/* .github/ISSUE_TEMPLATE/ || true | |
| # 如果有备份的配置文件,恢复它(保持仓库特定的配置) | |
| if [ -f "config-backup.yml" ]; then | |
| cp config-backup.yml .github/ISSUE_TEMPLATE/config.yml | |
| rm config-backup.yml | |
| fi | |
| # 清理临时目录 | |
| rm -rf temp-templates | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| # 检查是否有文件变更 | |
| if git diff --quiet; then | |
| echo "changes=false" >> $GITHUB_OUTPUT | |
| echo "🔄 没有检测到模板变更" | |
| else | |
| echo "changes=true" >> $GITHUB_OUTPUT | |
| echo "📝 检测到模板变更" | |
| git status | |
| git diff --name-only | |
| fi | |
| - name: Commit and push if changes | |
| if: steps.changes.outputs.changes == 'true' | |
| run: | | |
| git add .github/ISSUE_TEMPLATE/ | |
| git commit -m "🔁 chore: 自动同步最新的 issue 模板 [skip ci]" | |
| git push origin main | |
| echo "✅ 模板同步完成并已提交" | |
| - name: No changes | |
| if: steps.changes.outputs.changes == 'false' | |
| run: | | |
| echo "✅ 模板已是最新版本,无需更新" |