Skip to content

Add a GitHub action #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,44 @@ If **labels** encounters any errors while sending requests to the GitHub API,
it will print information about the failure and continue with the next label
until it has processed all of the labels.

### GitHub action
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


This repo also offers a composite GitHub action that can be used to sync
labels on each push to the default branch. To use it, create a workflow file
in your repo's ``.github/workflows`` directory with the following content:

```yaml
name: Sync Github labels

on:
push:
branches:
- main
paths:
- ".github/**"

jobs:
labels:
runs-on: ubuntu-latest

permissions:
# Permissions required to sync labels
issues: write

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Sync config with Github
uses: hackebrot/labels@main
with:
username: ${{ github.repository_owner }} # required
token: ${{ secrets.GITHUB_TOKEN }} # required
filename: .github/labels.toml # optional, this is the default value
```

## Community

Please check out the [good first issue][good first issue] label for tasks,
Expand Down
28 changes: 28 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Labels"
description: "Sync Github labels"

inputs:
token:
description: "GitHub access token"
required: true
username:
description: "GitHub username"
required: true
filename:
description: "Filename for labels"
default: ".github/labels.toml"

runs:
using: "composite"
steps:
- name: Install labels
run: pip install labels
shell: bash
- name: Sync config with GitHub
run: |
labels \
-t ${{ inputs.token }} \
-u ${{ inputs.username }} \
sync \
-f ${{ inputs.filename }}
shell: bash