Skip to content

Commit

Permalink
ci: add script to sync labels on the repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Tchoupinax committed Nov 25, 2024
1 parent 2fd03ab commit 9ca3f3e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/update-labels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

REPO_NAME="iggy-rs/setup-iggy"
API_URL="https://api.github.com/repos/$REPO_NAME/labels"

create_label() {
local name="$1"
local color="$2"
local description="$3"

curl -X POST -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \
-d '{"name": "'"$name"'", "color": "'"$color"'", "description": "'"$description"'"}' \
"$API_URL"
}

create_label "CI/CD" "93ecdb" "Pull requests bring CI/CD improvements."
create_label "docs" "0075ca" "Improvements or additions to documentation."
create_label "duplicate" "cfd3d7" "This issue or pull request already exists."
create_label "maintenance" "ed4d86" "Maintenance work."
create_label "semver:major" "8151c5" "Label for pull request that brings a major (BREAKING) change."
create_label "semver:minor" "8af85b" "Label for pull request that brings a minor change."
create_label "semver:patch" "fef2c0" "Label for pull request that brings a patch change."
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:

- uses: actions/checkout@v4
with:
fetch-depth: 1
token: ${{ steps.app-token.outputs.token }}
# Make sure the value of GITHUB_TOKEN will not be persisted in repo's config
persist-credentials: false
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:

- uses: actions/checkout@v4
with:
fetch-depth: 1
token: ${{ steps.app-token.outputs.token }}

- name: Update CHANGELOG
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/update-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Update repository labels
on:
pull_request:

jobs:
checks:
name: Update labels
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.DEPLOY_APP_ID }}
private-key: ${{ secrets.DEPLOY_APP_KEY }}

- name: Call script
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: .github/update-labels.sh

0 comments on commit 9ca3f3e

Please sign in to comment.