Skip to content

Commit 581c043

Browse files
authored
Merge pull request #322 from guardian/aa/revision
fix: Correctly obtain revision
2 parents 07ef53d + c8a72ec commit 581c043

4 files changed

Lines changed: 32 additions & 2 deletions

File tree

dist/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65943,6 +65943,14 @@ var getRoleArn = () => {
6594365943
}
6594465944
return roleArn;
6594565945
};
65946+
var getRevision = () => {
65947+
if (context2.eventName === "pull_request") {
65948+
const payload2 = context2.payload;
65949+
return payload2.pull_request.head.sha;
65950+
} else {
65951+
return context2.sha;
65952+
}
65953+
};
6594665954
function getConfiguration() {
6594765955
const riffRaffYaml = getRiffRaffYaml();
6594865956
const projectName = getProjectName(riffRaffYaml);
@@ -65963,7 +65971,7 @@ function getConfiguration() {
6596365971
buildNumber,
6596465972
branchName: branchName() ?? "dev",
6596565973
vcsURL: vcsURL() ?? "dev",
65966-
revision: envOrUndefined("GITHUB_SHA") ?? "dev",
65974+
revision: getRevision(),
6596765975
deployments: getDeployments(),
6596865976
stagingDirInput,
6596965977
githubToken: githubToken(),

package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@guardian/eslint-config": "14.0.1",
3232
"@guardian/prettier": "^10.0.0",
3333
"@guardian/tsconfig": "^1.0.1",
34+
"@octokit/webhooks-definitions": "^3.68.1",
3435
"@types/jest": "30.0.0",
3536
"@types/js-yaml": "^4.0.9",
3637
"@types/node": "25.6.0",

src/config.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import * as core from '@actions/core';
2+
import { context } from '@actions/github';
3+
import type { PullRequestEvent } from '@octokit/webhooks-definitions/schema';
24
import * as yaml from 'js-yaml';
35
import { read } from './file';
46
import type { Deployment, RiffraffYaml } from './riffraff';
@@ -190,6 +192,16 @@ const getRoleArn = (): string => {
190192
return roleArn;
191193
};
192194

195+
const getRevision = (): string => {
196+
if (context.eventName === 'pull_request') {
197+
// See https://github.com/orgs/community/discussions/26325
198+
const payload = context.payload as PullRequestEvent;
199+
return payload.pull_request.head.sha;
200+
} else {
201+
return context.sha;
202+
}
203+
};
204+
193205
export function getConfiguration(): Configuration {
194206
const riffRaffYaml = getRiffRaffYaml();
195207
const projectName = getProjectName(riffRaffYaml);
@@ -215,7 +227,7 @@ export function getConfiguration(): Configuration {
215227
buildNumber,
216228
branchName: branchName() ?? 'dev',
217229
vcsURL: vcsURL() ?? 'dev',
218-
revision: envOrUndefined('GITHUB_SHA') ?? 'dev',
230+
revision: getRevision(),
219231
deployments: getDeployments(),
220232
stagingDirInput,
221233
githubToken: githubToken(),

0 commit comments

Comments
 (0)