Skip to content

Commit

Permalink
feat: refactored set-default-labels
Browse files Browse the repository at this point in the history
  • Loading branch information
prisis committed May 20, 2024
1 parent d1aebcf commit 2138464
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 136 deletions.
125 changes: 125 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
## more info https://github.com/crazy-max/ghaction-github-labeler

- name: "s: needs decision"
description: "Needs team/maintainer decision"
color: "C453C3"

- name: "s: needs proposal"
description: "Changelog Fixed"
color: "fbca04"

- name: "s: needs design"
description: "Changelog Fixed"
color: "fbca04"

- name: "s: accepted"
description: "Accepted feature / Confirmed bug"
color: "0E8A16"

- name: "s: awaiting more info"
description: "Additional information are requested"
color: "B76026"

- name: "s: invalid"
description: "This doesn't seem right"
color: "E4E669"

- name: "s: on hold"
description: "Blocked by something or frozen to avoid conflicts"
color: "A03F0B"

- name: "s: pending triage"
description: "Pending Triage"
color: "dddddd"

- name: "s: waiting for user interest"
description: "Waiting for more users interested in this feature"
color: "4B02CE"

- name: "s: wontfix"
description: "This will not be worked on"
color: "ffffff"

- name: "question"
description: "Further information is requested"
color: "956692"

- name: "p: 1-normal"
description: "Nothing urgent"
color: "BFDADC"

- name: "p: 2-high"
description: "Fix main branch"
color: "FF4d4d"

- name: "p: 3-urgent"
description: "Fix and release ASAP"
color: "FF0000"

- name: "needs test"
description: "More tests are needed"
color: "FAF1A2"

- name: "needs rebase"
description: "There is a merge conflict"
color: "32345B"

- name: "c: bug"
description: "Something isn't working"
color: "FFA500"

- name: "c: chore"
description: "PR that doesn't affect the runtime behavior"
color: "40E0D0"

- name: "c: docs"
description: "Improvements or additions to documentation"
color: "FFFF00"

- name: "c: dependencies"
description: "Pull requests that adds/updates a dependency"
color: "AFEEEE"

- name: "c: feature"
description: "Request for new feature"
color: "2878FF"

- name: "c: infra"
description: "Changes to our infrastructure or project setup"
color: "2c3e50"

- name: "c: refactor"
description: "PR that affects the runtime behavior, but doesn't add new features or fixes bugs"
color: "40E0D0"

- name: "c: security"
description: "Indicates a vulnarability"
color: "B60205"

- name: "deprecation"
description: "A deprecation was made in the PR"
color: "C5DEF5"

- name: "do NOT merge yet"
description: "Do not merge this PR into the target branch yet"
color: "FF0205"

- name: "duplicate"
description: "Duplicate of another issue/PR"
color: "fef2c0"

- name: "good first issue"
description: "Good for newcomers"
color: "7057ff"

- name: "has workaround"
description: "Workaround provided or linked"
color: "4049AD"

- name: "help wanted"
description: "Extra attention is needed"
color: "008672"

- name: "breaking change"
description: "Cannot be merged when next version is not a major release"
color: "B05D08"
128 changes: 0 additions & 128 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,134 +40,6 @@ branches:
teams: null
users: null

# https://docs.github.com/en/rest/reference/issues#create-a-label
# https://docs.github.com/en/rest/reference/issues#update-a-label

labels:
- name: "s: needs decision"
description: "Needs team/maintainer decision"
color: "C453C3"

- name: "s: needs proposal"
description: "Changelog Fixed"
color: "fbca04"

- name: "s: needs design"
description: "Changelog Fixed"
color: "fbca04"

- name: "s: accepted"
description: "Accepted feature / Confirmed bug"
color: "0E8A16"

- name: "s: awaiting more info"
description: "Additional information are requested"
color: "B76026"

- name: "s: invalid"
description: "This doesn't seem right"
color: "E4E669"

- name: "s: on hold"
description: "Blocked by something or frozen to avoid conflicts"
color: "A03F0B"

- name: "s: pending triage"
description: "Pending Triage"
color: "dddddd"

- name: "s: waiting for user interest"
description: "Waiting for more users interested in this feature"
color: "4B02CE"

- name: "wontfix"
description: "This will not be worked on"
color: "ffffff"

- name: "question"
description: "Further information is requested"
color: "956692"

- name: "p: 1-normal"
description: "Nothing urgent"
color: "BFDADC"

- name: "p: 2-high"
description: "Fix main branch"
color: "FF4d4d"

- name: "p: 3-urgent"
description: "Fix and release ASAP"
color: "FF0000"

- name: "needs test"
description: "More tests are needed"
color: "FAF1A2"

- name: "needs rebase"
description: "There is a merge conflict"
color: "32345B"

- name: "c: bug"
description: "Something isn't working"
color: "FFA500"

- name: "c: chore"
description: "PR that doesn't affect the runtime behavior"
color: "40E0D0"

- name: "c: docs"
description: "Improvements or additions to documentation"
color: "FFFF00"

- name: "c: dependencies"
description: "Pull requests that adds/updates a dependency"
color: "AFEEEE"

- name: "c: feature"
description: "Request for new feature"
color: "2878FF"

- name: "c: infra"
description: "Changes to our infrastructure or project setup"
color: "2c3e50"

- name: "c: refactor"
description: "PR that affects the runtime behavior, but doesn't add new features or fixes bugs"
color: "40E0D0"

- name: "c: security"
description: "Indicates a vulnarability"
color: "B60205"

- name: "deprecation"
description: "A deprecation was made in the PR"
color: "C5DEF5"

- name: "do NOT merge yet"
description: "Do not merge this PR into the target branch yet"
color: "FF0205"

- name: "duplicate"
description: "Duplicate of another issue/PR"
color: "fef2c0"

- name: "good first issue"
description: "Good for newcomers"
color: "7057ff"

- name: "has workaround"
description: "Workaround provided or linked"
color: "4049AD"

- name: "help wanted"
description: "Extra attention is needed"
color: "008672"

- name: "breaking change"
description: "Cannot be merged when next version is not a major release"
color: "B05D08"

# https://docs.github.com/en/rest/reference/repos#update-a-repository

repository:
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ To use these workflows, simply reference them from your project's workflows. Ins

Read more about [reusing workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows).

### Repository Settings

Configure GitHub Actions permissions: Go to repo Settings > Actions > General and make sure to
configure the following:

- `Actions permissions` should be set to `Allow all actions and reusable workflows`
- `Workflow permissions` should be set to `Read and write permissions`, and make sure the
`Allow GitHub Actions to create and approve pull requests` option is active.

## Available steps and workflows

### Steps
Expand Down
14 changes: 11 additions & 3 deletions workflow/set-default-labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ Specify the target repository this action should run on. This is used to prevent

### Optional inputs

#### should-delete-labels
#### skip-delete

This is an optional `boolean` input that is `false` by default. If set to `true`, the action will delete any existing labels that are not listed in the JSON file mentioned previously.
This is an optional `boolean` input that is `false` by default. If set to `true`, the action will not delete labels not found in the YAML file.

#### yaml-file

Path to YAML file containing labels definitions. `(default .github/labels.yml)`

#### dry-run

This is an optional `boolean` input that is `"${{ github.event_name == 'pull_request' }}"` by default. If set to `true`, changes will not be applied.

## Usage

Expand Down Expand Up @@ -72,7 +80,7 @@ jobs:
uses: "anolilab/workflows/workflow/set-default-labels.yml@main"
with:
target-repo: "anolilab/workflows"
should-delete-labels: true
skip-delete: false
```
Because of the nature of this action, it must be run manually. You can learn more about [manually running actions on GitHub](https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow).
25 changes: 20 additions & 5 deletions workflow/set-default-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,35 @@ on: # yamllint disable-line rule:truthy
description: "The repo to run this action on. This is to prevent actions from running on forks unless intended."
required: true
type: "string"
should-delete-labels:
skip-delete:
description: "Delete labels that are not in the list"
default: false
required: false
type: "boolean"
dry-run:
description: "If enabled, changes will not be applied.",
default: "${{ github.event_name == 'pull_request' }}"
required: false
type: "boolean"
yaml-file:
description: "Path to YAML file containing labels definitions.",
default: ".github/labels.yml"
required: false
type: "string"

permissions:
# Issues and related comments, assignees, labels, and milestones.
issues: write

jobs:
set-default-labels:
if: "github.repository == inputs.target-repo"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "lannonbr/issue-label-manager-action@4.0.0"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- uses: "crazy-max/ghaction-github-labeler@de749cf181958193cb7debf1a9c5bb28922f3e1b" # v5.0.0
with:
delete: "${{ inputs.should-delete-labels }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"
yaml-file: "${{ inputs.yaml-file }}"
dry-run: "${{ inputs.dry-run }}"
skip-delete: "${{ inputs.skip-delete }}"

0 comments on commit 2138464

Please sign in to comment.