Skip to content

Commit be33864

Browse files
authored
fix: get PR title dynamically (#53)
This should remove some confusion about re-checking a changed PR title without a new CI event trigger
1 parent 3347398 commit be33864

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

.github/workflows/pre-commit.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Run pre-commit
22

33
on:
44
workflow_call:
5-
inputs:
5+
inputs:
66
commands:
77
required: false
88
type: string
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
2020
id: python-setup
2121
with:
22-
python-version: '3.x'
22+
python-version: "3.x"
2323
- name: Run commands
2424
if: inputs.commands
2525
run: ${INPUTS_COMMANDS}
@@ -28,7 +28,7 @@ jobs:
2828
- name: Cache pre-commit environments
2929
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
3030
with:
31-
path: '~/.cache/pre-commit'
31+
path: "~/.cache/pre-commit"
3232
key: pre-commit-${{ steps.python-setup.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
3333
- run: pipx run pre-commit run --show-diff-on-failure --color=always --all-files
3434

@@ -55,6 +55,15 @@ jobs:
5555
persist-credentials: false
5656
repository: cpp-linter/.github
5757
path: org-repo
58+
- name: Get PR title
59+
id: get-title
60+
env:
61+
GH_REPO: ${{ github.repository }}
62+
GH_TOKEN: ${{ github.token }}
63+
PR_NUMBER: ${{ github.event.pull_request.number }}
64+
run: |-
65+
pr_title=$(gh pr view "${PR_NUMBER}" --repo "${GH_REPO}" --json "title" -q ".title")
66+
echo "title=${pr_title}" >> "${GITHUB_OUTPUT}"
5867
- run: rustup update --no-self-update
5968
- name: Install cargo-binstall
6069
uses: cargo-bins/cargo-binstall@2bb61346d075e720d4c3da92f23b6d612d5a7543 # v1.15.3
@@ -64,15 +73,14 @@ jobs:
6473
GITHUB_TOKEN: ${{ github.token }}
6574
- name: conventional-commit
6675
env:
67-
PR_TITLE: ${{ github.event.pull_request.title }}
68-
run: >-
69-
echo "${PR_TITLE}"
70-
| committed --config ${{ github.workspace }}/org-repo/.github/committed.toml --commit-file -
76+
PR_TITLE: "${{ steps.get-title.outputs.title }}"
77+
COMMITTED_CONFIG: ${{ github.workspace }}/org-repo/.github/committed.toml
78+
run: echo "${PR_TITLE}" | committed --config "${COMMITTED_CONFIG}" --commit-file -
7179
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
7280
with:
7381
node-version: latest
7482
- name: spell check
7583
working-directory: project-repo
7684
env:
77-
PR_TITLE: ${{ github.event.pull_request.title }}
85+
PR_TITLE: "${{ steps.get-title.outputs.title }}"
7886
run: echo "${PR_TITLE}" | npx cspell-cli lint stdin

0 commit comments

Comments
 (0)