-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (44 loc) · 1.63 KB
/
label-sync.yml
File metadata and controls
50 lines (44 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Sync labels from labels.yml
on:
push:
branches: [main]
paths: [.github/labels.yml]
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
environment: automation
# permissions for GITHUB_TOKEN (used by EndBug/label-sync on this repo only).
# Cross-repo operations use GH_PAT_WORKFLOW_DISPATCH PAT instead.
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@v6
# Step 1: Sync labels.yml -> this repo's GitHub labels via EndBug/label-sync.
# This ensures .github repo matches the file before step 2 clones from it.
- name: Sync labels to this repo from labels.yml
uses: EndBug/label-sync@v2
with:
config-file: .github/labels.yml
delete-other-labels: true
# Step 2: Clone from .github (now guaranteed in sync with labels.yml) to
# all other public repos. Private repos are intentionally excluded.
- name: Sync labels to all other public repos
env:
GH_TOKEN: ${{ secrets.GH_PAT_WORKFLOW_DISPATCH }}
run: |
repos=$(gh repo list JacobPEvans --public --json name --limit 100 \
| jq -r '.[].name | select(. != ".github")') || {
echo "Error: Failed to fetch repository list"
exit 1
}
if [ -z "$repos" ]; then
echo "Warning: No repositories found to sync"
exit 0
fi
for repo in $repos; do
echo "Syncing labels to $repo..."
gh label clone JacobPEvans/.github -R "JacobPEvans/$repo" --force || \
echo " Warning: failed to sync $repo"
done