Repository navigation
feat(merge_requests): show original multiline discussion context #1844
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Triage | ||
|
Check warning on line 1 in .github/workflows/triage.yml
|
||
| # One workflow, so pull request labelling is deterministic. Two separate | ||
| # workflows (a labeler and a titler) ran as concurrent runs and raced: the | ||
| # area labels and the type label were applied in an undefined order, and | ||
| # actions/labeler removed a type label that another run had just added. Here | ||
| # every pull request step runs in one job, in order, so the last write wins | ||
| # predictably. | ||
| on: | ||
| issues: | ||
| types: [opened, reopened] | ||
| pull_request_target: | ||
| types: [opened, edited, reopened, synchronize] | ||
| # pull_request_target, not pull_request: a fork's pull request needs a | ||
| # write-scoped token to be labelled and assigned, which pull_request does not | ||
| # grant. Safe here only because no step checks out or executes the | ||
| # contributor's code — every step operates on metadata through the API. | ||
| permissions: | ||
| contents: read | ||
| issues: write | ||
| pull-requests: write | ||
| concurrency: | ||
| group: triage-${{ github.event.issue.number || github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| triage-issue: | ||
| name: Triage new issue | ||
| if: github.event_name == 'issues' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Mark as needing triage and assign a maintainer | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| REPO: ${{ github.repository }} | ||
| NUMBER: ${{ github.event.issue.number }} | ||
| run: | | ||
| gh issue edit "$NUMBER" --repo "$REPO" --add-label "status:needs-triage" | ||
| # --add-assignee is best effort: it fails when the account cannot be | ||
| # assigned, which must not fail the whole run. | ||
| gh issue edit "$NUMBER" --repo "$REPO" --add-assignee sjungwon03 || \ | ||
| echo "Could not assign sjungwon03; leaving the issue unassigned." | ||
| triage-pull-request: | ||
| name: Triage pull request | ||
| if: github.event_name == 'pull_request_target' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| # Area labels first, from the changed paths. sync-labels stays false so | ||
| # this cannot strip a label it does not manage; the type label is applied | ||
| # in the next step and must survive. | ||
| - name: Apply area labels | ||
| uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5 | ||
| with: | ||
| configuration-path: .github/labeler.yml | ||
| sync-labels: false | ||
| # Type label second, so it lands after labeler and cannot be removed by | ||
| # it. The change type comes from the title, not the changed files: a | ||
| # one-line change under packages/gitlab_api can be a fix, a feat or a | ||
| # refactor. | ||
| - name: Label pull request by type | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| REPO: ${{ github.repository }} | ||
| NUMBER: ${{ github.event.pull_request.number }} | ||
| TITLE: ${{ github.event.pull_request.title }} | ||
| run: | | ||
| set -euo pipefail | ||
| # feat(scope)!: subject -> feat | ||
| TYPE="$(printf '%s' "$TITLE" | sed -nE 's/^([a-z]+)(\([^)]*\))?!?:.*/\1/p')" | ||
| if [ -z "$TYPE" ]; then | ||
| echo "Title is not a Conventional Commit; no type label applied." | ||
| echo "Got: $TITLE" | ||
| exit 0 | ||
| fi | ||
| case "$TYPE" in | ||
| feat|fix|docs|refactor|test|chore) | ||
| echo "Applying type label: $TYPE" | ||
| gh pr edit "$NUMBER" --repo "$REPO" --add-label "$TYPE" | ||
| ;; | ||
| *) | ||
| echo "Unknown Conventional Commit type '$TYPE'; no label applied." | ||
| ;; | ||
| esac | ||
| - name: Assign the author | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| REPO: ${{ github.repository }} | ||
| NUMBER: ${{ github.event.pull_request.number }} | ||
| AUTHOR: ${{ github.event.pull_request.user.login }} | ||
| run: | | ||
| gh pr edit "$NUMBER" --repo "$REPO" --add-assignee "$AUTHOR" || \ | ||
| echo "Could not assign $AUTHOR; outside contributors cannot be assignees." | ||