Skip to content
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

ci: add labeller and labels script #1392

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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
45 changes: 45 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: v1
labels:
- label: "semver:major"
sync: true # remove label if match failed, default: false
matcher:
title: ".*BREAKING.*"

- label: "semver:minor"
sync: true # remove label if match failed, default: false
matcher:
title: "^feat(?!.*BREAKING).*"

- label: "semver:patch"
sync: true # remove label if match failed, default: false
matcher:
title: "^fix(?!.*BREAKING).*"

- label: "maintenance"
sync: true # remove label if match failed, default: false
matcher:
title: "^chore(?!.*BREAKING).*"
files:
any:
- "package.json"

- label: "CI/CD"
sync: true # remove label if match failed, default: false
matcher:
files:
any:
- ".github/**"

- label: "docs"
sync: true # remove label if match failed, default: false
matcher:
files:
any:
- "**/*.md"

- label: "manifest"
sync: true # remove label if match failed, default: false
matcher:
files:
any:
- "action.yml"
23 changes: 23 additions & 0 deletions .github/update-labels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

REPO_NAME="iggy-rs/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 "manifest" "D93F0B" "Label for pull request that brings a patch change."
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."
32 changes: 32 additions & 0 deletions .github/workflows/master-update-labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Update repository labels
on:
push:
branches:
- master
paths:
- ".github/workflows/uptdate-label.yml"
- ".github/update-labels.sh"

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: |
chmod +x .github/update-labels.sh
.github/update-labels.sh
23 changes: 23 additions & 0 deletions .github/workflows/pull-request-relabelling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Relabelling
Copy link
Collaborator

Choose a reason for hiding this comment

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

make it start with r to match rest of workflows in this project, same for line 7

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Both done :)

on:
pull_request:

jobs:
check-labels:
name: Relabelling
runs-on: ubuntu-latest
permissions:
pull-requests: write

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

# https://github.com/fuxingloh/multi-labeler
- name: labels
uses: fuxingloh/multi-labeler@v4
with:
github-token: ${{ steps.app-token.outputs.token }}
29 changes: 4 additions & 25 deletions .github/workflows/sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,33 +68,12 @@ jobs:
- name: Check subject line length
uses: gsactions/commit-message-checker@v2
with:
excludeDescription: 'false' # exclude description body of a pull request
excludeTitle: 'false' # exclude the title of a pull request
checkAllCommitMessages: 'false' # checks all commits associated with the pull request
excludeDescription: "false" # exclude description body of a pull request
excludeTitle: "false" # exclude the title of a pull request
checkAllCommitMessages: "false" # checks all commits associated with the pull request
accessToken: ${{ secrets.GITHUB_TOKEN }} # needed only when checkAllCommitMessages is true
pattern: '^.{0,80}(\n.*)*$'
error: 'Subject of all commits in the PR and PR body/title has to be shorter than 80 characters.'

- name: Disallow specific prefixes in title
uses: gsactions/commit-message-checker@v2
with:
excludeDescription: 'true'
excludeTitle: 'true'
checkAllCommitMessages: 'true'
accessToken: ${{ secrets.GITHUB_TOKEN }}
pattern: '^(?!(.*(feat|fix|docs|style|refactor|perf|test|chore):.*(\n.*)*$)).*'
error: 'Do not use prefixes like "feat:", "fix:", etc., in the subject of any commit in the PR.'

- name: Disallow lowercase subject
uses: gsactions/commit-message-checker@v2
with:
excludeDescription: 'true'
excludeTitle: 'false'
checkAllCommitMessages: 'false'
accessToken: ${{ secrets.GITHUB_TOKEN }}
pattern: '^[A-Z].*(\n.*)*$'
error: 'Subject of title in the PR has to start with a capital letter.'

error: "Subject of all commits in the PR and PR body/title has to be shorter than 80 characters."
# Uncomment this when we have a proper release - 1.0.0
# semver-checks:
# name: SemVer SDK
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
pull_request:
branches:
- master
types: [ opened, synchronize, reopened ]
types: [opened, synchronize, reopened]

env:
CRATE_NAME: iggy
Expand Down
Loading