Skip to content

Commit 9e99c30

Browse files
committed
Add a GitHub action
1 parent 2a36720 commit 9e99c30

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

README.md

+38
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,44 @@ If **labels** encounters any errors while sending requests to the GitHub API,
157157
it will print information about the failure and continue with the next label
158158
until it has processed all of the labels.
159159

160+
### GitHub action
161+
162+
This repo also offers a composite GitHub action that can be used to sync
163+
labels on each push to the default branch. To use it, create a workflow file
164+
in your repo's ``.github/workflows`` directory with the following content:
165+
166+
```yaml
167+
name: Sync Github labels
168+
169+
on:
170+
push:
171+
branches:
172+
- main
173+
paths:
174+
- ".github/**"
175+
176+
jobs:
177+
labels:
178+
runs-on: ubuntu-latest
179+
180+
permissions:
181+
# Permissions required to sync labels
182+
issues: write
183+
184+
steps:
185+
- uses: actions/checkout@v4
186+
- name: Set up Python
187+
uses: actions/setup-python@v4
188+
with:
189+
python-version: 3.x
190+
- name: Sync config with Github
191+
uses: hackebrot/labels@main
192+
with:
193+
username: ${{ github.repository_owner }} # required
194+
token: ${{ secrets.GITHUB_TOKEN }} # required
195+
filename: .github/labels.toml # optional, this is the default value
196+
```
197+
160198
## Community
161199
162200
Please check out the [good first issue][good first issue] label for tasks,

action.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Labels"
2+
description: "Sync Github labels"
3+
4+
inputs:
5+
token:
6+
description: "GitHub access token"
7+
required: true
8+
username:
9+
description: "GitHub username"
10+
required: true
11+
filename:
12+
description: "Filename for labels"
13+
default: ".github/labels.toml"
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Install labels
19+
run: pip install labels
20+
shell: bash
21+
- name: Sync config with GitHub
22+
run: |
23+
labels \
24+
-t ${{ inputs.token }} \
25+
-u ${{ inputs.username }} \
26+
sync \
27+
-f ${{ inputs.filename }}
28+
shell: bash

0 commit comments

Comments
 (0)