From 9e99c30706a00e70ecadc3a51e23adcae9cddb2e Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Thu, 12 Oct 2023 14:30:42 +0100 Subject: [PATCH] Add a GitHub action --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ action.yml | 28 ++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 action.yml diff --git a/README.md b/README.md index 99120f2..0792cc1 100644 --- a/README.md +++ b/README.md @@ -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 + +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, diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..cf1eb85 --- /dev/null +++ b/action.yml @@ -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