Skip to content

Commit 64d4238

Browse files
committed
fix: use GITHUB_SHA environment variable
1 parent 51dd5f4 commit 64d4238

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

lib/run.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ import uploadToS3 from './utils/upload-to-s3.js'
99

1010
export async function run() {
1111
const inputs = getInputs()
12-
const octokit = github.getOctokit(inputs.ghToken, { request: { fetch } })
12+
let octokitOptions
13+
14+
if (process.env.IS_LOCAL_DEV) {
15+
octokitOptions = { request: { fetch } }
16+
}
17+
18+
const octokit = github.getOctokit(inputs.ghToken, octokitOptions)
1319
const commitResponse = await octokit.rest.git.getCommit({
1420
owner: github.context.repo.owner,
1521
repo: github.context.repo.repo,
16-
commit_sha: process.env.COMMIT_SHA,
22+
commit_sha: process.env.GITHUB_SHA,
1723
})
1824

1925
const globber = await glob.create(inputs.filePattern, {

test/run.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import nock from 'nock'
22
import { after, before, beforeEach, describe, it } from 'node:test'
3+
import { TEST_GITHUB_SHA } from '../lib/constants.js'
34

45
import { run } from '../lib/run.js'
56
import getCommitInfo from './_helpers/get-commit-info.js'
@@ -22,7 +23,7 @@ describe('run', async () => {
2223

2324
await it('should upload files and create index', async ({ assert }) => {
2425
nock('https://api.github.com')
25-
.get('/repos/me/my-repo/git/commits')
26+
.get(`/repos/me/my-repo/git/commits/${TEST_GITHUB_SHA}`)
2627
.reply(200, getCommitInfo())
2728
await run()
2829
const s3Objects = await getS3Objects()

0 commit comments

Comments
 (0)