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

feat(ci): 🔖 add appropriate labels to PRs with failed checks #2793

Open
wants to merge 18 commits 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
24 changes: 24 additions & 0 deletions .github/scripts/update-status-label.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

# Only for GitHub Actions
# Parameters: <pr_number> <status> <label>
# Example: ./update-status-label.sh 1234 failure "invalid-colors"

# Exit on error
set -e

pr_number="$1"
status="$2"
label="$3"

action="add-label" && [ "$status" == "success" ] && action="remove-label"

# Add or remove label
export GH_TOKEN="$GITHUB_TOKEN"
gh pr edit "$pr_number" --$action "$label"

[ "$action" == "add-label" ] && echo "✅ Added \"$label\" label to PR #$pr_number"
[ "$action" == "remove-label" ] && echo "✅ Removed \"$label\" label from PR #$pr_number"

# 0 = success
exit 0
11 changes: 9 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ on:

permissions:
contents: read
pull-requests: write
issues: write # Update issue labels

jobs:
build:
Expand All @@ -37,8 +39,6 @@ jobs:
steps:
- name: 📥 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: 🔧 Setup Bun
uses: oven-sh/setup-bun@4bc047ad259df6fc24a6c9b0f9a0cb08cf17fbe5 # v2
Expand All @@ -49,6 +49,13 @@ jobs:
run: bun install --frozen-lockfile

- name: 🚀 Test + Build
id: build
run: |
bun test
bun run vscode:prepublish

- name: 🏷️ Manage label based on build result
if: ${{ always() && github.event_name == 'pull_request' }}
run: .github/scripts/update-status-label.sh ${{ github.event.pull_request.number }} ${{ steps.build.outcome }} "❌ failed build"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 10 additions & 1 deletion .github/workflows/color-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:

permissions:
contents: read
pull-requests: write
issues: write # Update issue labels

jobs:
color-check:
Expand All @@ -19,9 +21,9 @@ jobs:
- name: 📥 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
sparse-checkout-cone-mode: false
sparse-checkout: |
.github/scripts/update-status-label.sh
material-colors.yml
icons/

Expand All @@ -30,6 +32,13 @@ jobs:
git fetch origin $TARGET_BRANCH

- name: 🎨 Check colors
id: color-check
run: |
svgFiles=$(git diff origin/$TARGET_BRANCH --diff-filter=ACMRTUX --name-only | grep '.svg$')
npx svg-color-linter --config material-colors.yml ${svgFiles}

- name: 🏷️ Manage label based on color check result
if: always()
run: .github/scripts/update-status-label.sh ${{ github.event.pull_request.number }} ${{ steps.color-check.outcome }} "🎨 invalid colors"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 0 additions & 2 deletions .github/workflows/icon-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
path: fork
persist-credentials: false
sparse-checkout-cone-mode: false
sparse-checkout: |
icons/
Expand All @@ -36,7 +35,6 @@ jobs:
with:
fetch-depth: 0
path: main
persist-credentials: false
sparse-checkout-cone-mode: false
sparse-checkout: |
.bun-version
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

permissions:
pull-requests: write
issues: write # Update issue labels

jobs:
lint-pr-title:
Expand All @@ -21,13 +22,21 @@ jobs:
# Only fetch the config file from the repository
sparse-checkout-cone-mode: false
sparse-checkout: |
.github/scripts/update-status-label.sh
commitlint.config.js

- name: 📦 Install dependencies
run: npm install --global @commitlint/config-conventional commitlint

- name: 🔍 Check PR title with commitlint
id: title-check
env:
PR_TITLE: ${{ github.event.pull_request.title }}
HELP_URL: https://github.com/material-extensions/vscode-material-icon-theme/blob/main/CONTRIBUTING.md#conventional-pull-request-titles
run: echo "$PR_TITLE" | npx commitlint --help-url $HELP_URL

- name: 🏷️ Manage label based on PR title check result
if: always()
run: .github/scripts/update-status-label.sh ${{ github.event.pull_request.number }} ${{ steps.title-check.outcome }} "🔤 invalid title"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading