Files
phosphor-icons/.github/workflows/sync-docs.yaml
2024-12-29 01:09:41 -07:00

80 lines
2.1 KiB
YAML

name: Sync README links section
on:
push:
# paths:
# - 'README.md'
# branches:
# - master
workflow_dispatch: # Allows manual triggering
concurrency:
group: 'docs'
cancel-in-progress: true
jobs:
sync-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: source-repo
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
cache-dependency-path: source-repo/pnpm-lock.yaml
- name: Read repository list
id: repo-list
run: |
echo "repos<<EOF" >> $GITHUB_OUTPUT
cat source-repo/.github/sync-repos.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Sync to target repositories
env:
GH_TOKEN: ${{ github.token }}
run: |
for repo in ${{ steps.repo-list.outputs.repos }}; do
echo "Syncing to $repo"
# Clone target repository
gh repo clone $repo target-repo
# Run sync script
pnpm run sync-docs -- "$repo"
# Create PR if there are changes
cd target-repo
if [[ -n "$(git status --porcelain)" ]]; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Create branch
BRANCH="sync-readme-$(date +%Y%m%d-%H%M%S)"
git checkout -b $BRANCH
# Commit and push changes
git add README.md
git commit -m "Sync README section from master repository"
git push origin $BRANCH
# Create PR
gh pr create \
--title "chore(docs): sync readme section" \
--body "Automated PR to sync README section from master repository" \
--base main
fi
cd ..
rm -rf target-repo
done