Repository navigation
62 lines (56 loc) · 1.95 KB
/
Copy pathsync-labels.yml
File metadata and controls
62 lines (56 loc) · 1.95 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
51
52
53
54
55
56
57
58
59
60
61
62
name: Sync labels
# Mirrors `.github/labels.yml` to the GitHub repository's label set.
# Runs on every push to `main` that touches the source file, on PRs that
# modify it (dry-run for review), and on manual dispatch.
#
# The source file is the canonical taxonomy.
on:
push:
branches: [main]
paths:
- ".github/labels.yml"
- ".github/workflows/sync-labels.yml"
pull_request:
paths:
- ".github/labels.yml"
- ".github/workflows/sync-labels.yml"
workflow_dispatch:
inputs:
dry-run:
description: "Preview the diff without writing to GitHub"
type: boolean
required: false
default: false
permissions:
contents: read
issues: write
pull-requests: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
# Pull-request runs are always dry-run: we want to see the diff in
# the workflow logs before merging, but we never mutate the repo's
# label set from an unmerged change. Manual dispatch honours the
# `dry-run` input so maintainers can preview ad-hoc.
- name: Compute dry-run flag
id: mode
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "dry-run=true" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "dry-run=${{ inputs.dry-run }}" >> "$GITHUB_OUTPUT"
else
echo "dry-run=false" >> "$GITHUB_OUTPUT"
fi
- name: Sync labels from .github/labels.yml
uses: crazy-max/ghaction-github-labeler@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
yaml-file: .github/labels.yml
# Keep labels that are not in the source file (e.g. labels
# created by external integrations or third-party bots) so the
# sync is additive rather than destructive.
skip-delete: true
dry-run: ${{ steps.mode.outputs.dry-run }}