Skip to content

Commit 3dad2c1

Browse files
committed
ci: avoid double execution on PR
1 parent 8235787 commit 3dad2c1

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build, Test, Lint and Package
1+
name: Build, Test, Lint & Package
22

33
on:
44
workflow_dispatch:

.github/workflows/ci.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
name: CI
22

33
on:
4-
pull_request_target:
54
push:
65

76
jobs:
87
build:
8+
name: Build
99
uses: ./.github/workflows/build.yml
1010

11-
comment:
12-
name: Bot comment
11+
pr:
12+
name: PR
1313
needs: build
1414
runs-on: ubuntu-latest
15-
if: github.event_name == 'pull_request_target'
15+
if: github.head_ref
1616
env:
1717
MESSAGE_FILE: ./message.md
1818
steps:
19-
- name: Create message
19+
- name: Check if in PR
20+
uses: insurgent-lab/is-in-pr-action@v0.2.0
21+
id: is-pr
22+
23+
- name: Create PR comment
24+
id: create-comment
25+
if: ${{ steps.is-pr.outputs.result == 'true' }}
2026
run: |
2127
function outcome_emoji() {
2228
if [ "$1" == "success" ]; then
@@ -32,20 +38,24 @@ jobs:
3238
echo "$1" >> ${{ env.MESSAGE_FILE }}
3339
}
3440
35-
write "## :arrow_right: Commit ${{ github.event.pull_request.head.sha }}"
41+
write "## :arrow_right: Commit ${{ github.sha }}"
3642
write "## :hammer_and_wrench: Building result: $(outcome_emoji ${{ needs.build.outputs.build }})"
37-
write "### :package: Artifacts: $(outcome_emoji ${{ needs.build.outputs.artifact-url }})"
38-
write "1. [Download the tarball](${{ needs.build.outputs.artifact-url }})"
39-
write "2. \`unzip linux-enable-ir-emitter*.tar.gz.zip\`"
40-
write "3. [Execute the install instructions](https://github.com/EmixamPP/linux-enable-ir-emitter?tab=readme-ov-file#installation)"
43+
if [ "${{ needs.build.outputs.build }}" == "success" ]; then
44+
write "### :package: Artifacts:"
45+
write "1. [Download the tarball](${{ needs.build.outputs.artifact-url }})"
46+
write "2. \`unzip linux-enable-ir-emitter*.tar.gz.zip\`"
47+
write "3. [Execute the install instructions](https://github.com/EmixamPP/linux-enable-ir-emitter?tab=readme-ov-file#installation)"
48+
fi
4149
write ""
4250
write "## :test_tube: Tests results: $(outcome_emoji ${{ needs.build.outputs.tests }})"
4351
write "## :stethoscope: Clippy results: $(outcome_emoji ${{ needs.build.outputs.clippy }})"
4452
write "## :art: Format results: $(outcome_emoji ${{ needs.build.outputs.format }})"
4553
write "## :books: Doc results: $(outcome_emoji ${{ needs.build.outputs.doc }})"
4654
write "## :scissors: Shear results: $(outcome_emoji ${{ needs.build.outputs.shear }})"
4755
48-
- uses: thollander/actions-comment-pull-request@v3
56+
- name: Comment on PR
57+
uses: thollander/actions-comment-pull-request@v3
58+
if: ${{ steps.create-comment.outcome == 'success' }}
4959
with:
5060
comment-tag: bot_comment
5161
mode: recreate

0 commit comments

Comments
 (0)