fix(ci): use repos list

This commit is contained in:
rektdeckard
2024-12-28 22:09:19 -07:00
committed by Tobias Fried
parent a4421c82b2
commit b6d47ab575
2 changed files with 30 additions and 24 deletions

14
.github/sync-repos.txt vendored Normal file
View File

@@ -0,0 +1,14 @@
phosphor-icons/core
phosphor-icons/figma
phosphor-icons/flutter
phosphor-icons/penpot
phosphor-icons/phosphor-elm
phosphor-icons/play
phosphor-icons/react
phosphor-icons/sketch
phosphor-icons/swift
phosphor-icons/theme
phosphor-icons/unplugin
phosphor-icons/vue
phosphor-icons/web
phosphor-icons/webcomponents

View File

@@ -13,30 +13,14 @@ concurrency:
group: 'docs' group: 'docs'
cancel-in-progress: true cancel-in-progress: true
env:
# List of target repositories to sync to
TARGET_REPOS: >-
phosphor-icons/core
phosphor-icons/figma
phosphor-icons/flutter
phosphor-icons/penpot
phosphor-icons/phosphor-elm
phosphor-icons/play
phosphor-icons/react
phosphor-icons/sketch
phosphor-icons/swift
phosphor-icons/theme
phosphor-icons/unplugin
phosphor-icons/vue
phosphor-icons/web
phosphor-icons/webcomponents
jobs: jobs:
sync-docs: sync-docs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
path: source-repo
- name: Install pnpm - name: Install pnpm
uses: pnpm/action-setup@v4 uses: pnpm/action-setup@v4
@@ -49,34 +33,42 @@ jobs:
with: with:
node-version: 20 node-version: 20
cache: 'pnpm' cache: 'pnpm'
cache-dependency-path: source-repo/pnpm-lock.json
- 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 - name: Sync to target repositories
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
run: | run: |
echo "$TARGET_REPOS" | while read repo; do for repo in ${{ steps.repo-list.outputs.repos }}; do
echo "Syncing to $repo" echo "Syncing to $repo"
# Clone target repository # Clone target repository
gh repo clone $repo target-repo gh repo clone $repo target-repo
# Run sync script # Run sync script
pnpm run sync-docs -- "$repo" pnpm run sync-docs -- "$repo"
# Create PR if there are changes # Create PR if there are changes
cd target-repo cd target-repo
if [[ -n "$(git status --porcelain)" ]]; then if [[ -n "$(git status --porcelain)" ]]; then
git config user.name "github-actions[bot]" git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com" git config user.email "github-actions[bot]@users.noreply.github.com"
# Create branch # Create branch
BRANCH="sync-readme-$(date +%Y%m%d-%H%M%S)" BRANCH="sync-readme-$(date +%Y%m%d-%H%M%S)"
git checkout -b $BRANCH git checkout -b $BRANCH
# Commit and push changes # Commit and push changes
git add README.md git add README.md
git commit -m "Sync README section from master repository" git commit -m "Sync README section from master repository"
git push origin $BRANCH git push origin $BRANCH
# Create PR # Create PR
gh pr create \ gh pr create \
--title "Sync README section" \ --title "Sync README section" \