Skip to content

Commit 085f088

Browse files
committed
fix: support workflow_run events for github status
ensures commit statuses are posted to the correct sha when the action is triggered from a workflow_run context (e.g., secure fork pr workflows) applies the same fix as ipshipyard/ipfs-deploy-action#37
1 parent e7f1108 commit 085f088

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## Unreleased
9+
10+
### Added
911
- Added support for Gandi DNS provider
1012

13+
### Fixed
14+
- Support `workflow_run` events for correct GitHub commit status (e.g., secure fork PR workflows)
15+
1116
## [0.1.0] - 2025-02-20
1217

1318
- Initial release of of the dnslink-action

‎action.yml‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,18 @@ runs:
162162
script: |
163163
const cid = '${{ inputs.cid }}';
164164
165-
// For PR events, we need to use the head SHA
166-
const sha = context.eventName === 'pull_request'
167-
? context.payload.pull_request.head.sha
168-
: context.sha;
165+
// Determine the correct SHA based on the event type
166+
let sha;
167+
if (context.eventName === 'workflow_run') {
168+
// For workflow_run events triggered by PRs, use the PR's head SHA
169+
sha = context.payload.workflow_run.head_sha;
170+
} else if (context.eventName === 'pull_request' || context.eventName === 'pull_request_target') {
171+
// For PR events, use the head SHA
172+
sha = context.payload.pull_request.head.sha;
173+
} else {
174+
// For push events, use the commit SHA
175+
sha = context.sha;
176+
}
169177
170178
await github.rest.repos.createCommitStatus({
171179
owner: context.repo.owner,

0 commit comments

Comments
 (0)