Skip to content

Commit f5b8ee0

Browse files
authored
Refactor CI for forked repositories - Codacy - Bind to expected commit (#107)
1 parent 5f25c8e commit f5b8ee0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.github/actions/reports-group/codacy-uploader/action.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ inputs:
1212
description: |
1313
Indicates whether to follow symbolic links when resolving `path`
1414
default: 'true'
15+
override-commit:
16+
description: |
17+
Commit to link to the uploaded reports.
18+
Default value:
19+
- `push` workflow: `github.sha`
20+
- `pull_request` workflow: `github.event.pull_request.head.sha`
21+
- `workflow_run` workflow triggered by a `pull_request` or `push` workflow: `github.event.workflow_run.head_sha`
22+
default: "${{ ('workflow_run' == github.event_name && ('pull_request' == github.event.workflow_run.event || 'push' == github.event.workflow_run.event) && github.event.workflow_run.head_sha) || ('pull_request' == github.event_name && github.event.pull_request.head.sha) || ('push' == github.event_name && github.sha) || null }}"
1523

1624
outputs:
1725
groups:
@@ -78,6 +86,9 @@ runs:
7886
- name: Upload to codacy
7987
id: upload
8088
uses: codacy/codacy-coverage-reporter-action@v1
89+
env:
90+
GITHUB_SHA: ${{ inputs.override-commit }} # Lonely way to override the commit without having to deal with CLI uploader directly :/
91+
GITHUB_EVENT_NAME: push # Force the event to "push" to be sure uploader will leverage GITHUB_SHA and not something else (mostly in case event is `pull_request`)
8192
with:
8293
coverage-reports: ${{ steps.build-uploader-options.outputs.coverage-reports }}
8394
project-token: ${{ inputs.project-token }}

.github/actions/reports-group/codecov-uploader/action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ inputs:
1616
description: |
1717
Commit to link to the uploaded reports.
1818
Default value:
19-
- `push` and `pull_request` workflow: `github.event.after`
19+
- `push` workflow: `github.sha`
20+
- `pull_request` workflow: `github.event.pull_request.head.sha`
2021
- `workflow_run` workflow triggered by a `pull_request` or `push` workflow: `github.event.workflow_run.head_sha`
21-
default: "${{ ('workflow_run' == github.event_name && ('pull_request' == github.event.workflow_run.event || 'push' == github.event.workflow_run.event) && github.event.workflow_run.head_sha) || (('pull_request' == github.event_name || 'push' == github.event_name) && github.event.pull_request.head.sha) || null }}"
22+
default: "${{ ('workflow_run' == github.event_name && ('pull_request' == github.event.workflow_run.event || 'push' == github.event.workflow_run.event) && github.event.workflow_run.head_sha) || ('pull_request' == github.event_name && github.event.pull_request.head.sha) || ('push' == github.event_name && github.sha) || null }}"
2223
override-branch:
2324
description: |
2425
Branch to link to the uploaded reports.

0 commit comments

Comments
 (0)