Skip to content

Commit

Permalink
feat: add support for running on release event (#1191)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
jackton1 and actions-user authored May 29, 2023
1 parent 96fd197 commit 043929e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
12 changes: 7 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/commitSha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export const getSHAForPushEvent = async (
core.info('Repository is shallow, fetching more history...')

if (isTag) {
const sourceBranch = env.GITHUB_EVENT_BASE_REF.replace('refs/heads/', '')
const sourceBranch =
env.GITHUB_EVENT_BASE_REF.replace('refs/heads/', '') ||
env.GITHUB_EVENT_RELEASE_TARGET_COMMITISH
await gitFetch({
cwd: workingDirectory,
args: [
Expand Down
6 changes: 6 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type Env = {
GITHUB_REF_NAME: string
GITHUB_REF: string
GITHUB_EVENT_BASE_REF: string
GITHUB_EVENT_RELEASE_TARGET_COMMITISH: string
GITHUB_EVENT_HEAD_REPO_FORK: string
GITHUB_WORKSPACE: string
GITHUB_EVENT_FORCED: string
Expand All @@ -27,6 +28,9 @@ type GithubEvent = {
}
number: string
}
release?: {
target_commitish: string
}
before?: string
base_ref?: string
head_repo?: {
Expand All @@ -49,6 +53,8 @@ export const getEnv = async (): Promise<Env> => {
GITHUB_EVENT_PULL_REQUEST_BASE_REF: eventJson.pull_request?.base?.ref || '',
GITHUB_EVENT_BEFORE: eventJson.before || '',
GITHUB_EVENT_BASE_REF: eventJson.base_ref || '',
GITHUB_EVENT_RELEASE_TARGET_COMMITISH:
eventJson.release?.target_commitish || '',
GITHUB_EVENT_HEAD_REPO_FORK: eventJson.head_repo?.fork || '',
GITHUB_EVENT_PULL_REQUEST_NUMBER: eventJson.pull_request?.number || '',
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: eventJson.pull_request?.base?.sha || '',
Expand Down

0 comments on commit 043929e

Please sign in to comment.