Skip to content

Commit 84e1868

Browse files
committed
Fix installer: Add arguments to actions/checkout so that it checks out slsa-framework/slsa-verifier instead of the repo using the Action.
Signed-off-by: kpk47 <kkris@google.com>
1 parent e9cd6b7 commit 84e1868

File tree

6 files changed

+39
-27
lines changed

6 files changed

+39
-27
lines changed

actions/installer/action.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ branding:
2020
runs:
2121
using: 'composite'
2222
steps:
23+
- name: Get Action Ref
24+
shell: bash
25+
env:
26+
ACTION_REF: "${{ github.action_ref }}"
27+
run: echo "action_ref=$ACTION_REF" >> $GITHUB_ENV
2328
- name: Checkout
2429
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3.1.0
25-
30+
with:
31+
repository: "slsa-framework/slsa-verifier"
32+
ref: "${{ env.action_ref }}"
2633
- name: Setup Node.js 16
2734
uses: actions/setup-node@969bd2663942d722d85b6a8626225850c2f7be4b # tag=v3.5.0
2835
with:
@@ -45,4 +52,5 @@ runs:
4552
REPOSITORY: "${{ github.repository }}"
4653
working-directory: actions/installer/dist
4754
shell: bash
48-
run: nodejs index.js
55+
run: npm start
56+

actions/installer/dist/index.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,14 @@ function getVerifierVersion(actionRef) {
8282
const shaRe = /^[a-f\d]{40}$/;
8383
if (shaRe.test(actionRef)) {
8484
const octokit = github.getOctokit(process.env.TOKEN || "");
85-
const { data: releases } = yield octokit.request("GET /repos/{repository}/releases", {
86-
repository: process.env.REPOSITORY,
85+
const { data: tags } = yield octokit.request("GET /repos/{owner}/{repository}/tags", {
86+
owner: "slsa-framework",
87+
repository: "slsa-verifier",
8788
});
88-
for (const release of releases) {
89-
const { data: commit } = yield octokit.request("GET /reps/{repository}/git/ref/tags/{tagName}", {
90-
repository: process.env.REPOSITORY,
91-
tagName: release.tag_name,
92-
});
93-
const commitSha = commit.object.sha;
89+
for (const tag of tags) {
90+
const commitSha = tag.commit.sha;
9491
if (commitSha === actionRef) {
95-
return release.tag_name;
92+
return tag.name;
9693
}
9794
}
9895
}

actions/installer/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

actions/installer/package-lock.json

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

actions/installer/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111
"package": "ncc build --source-map",
1212
"lint": "eslint src/**/*.ts",
1313
"build": "npm run compile && npm run package",
14+
"start": "node lib/index.js",
1415
"all": "npm run compile && npm run format && npm run lint && npm run test && npm run package"
1516
},
1617
"dependencies": {
1718
"@actions/core": "^1.9.1",
1819
"@actions/exec": "^1.1.1",
1920
"@actions/github": "^5.0.3",
2021
"@actions/io": "^1.1.2",
21-
"@actions/tool-cache": "^2.0.1"
22+
"@actions/tool-cache": "^2.0.1",
23+
"nodejs": "^0.0.0"
2224
},
2325
"devDependencies": {
2426
"@types/jasmine": "4.3.0",

actions/installer/src/index.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,17 @@ export async function getVerifierVersion(actionRef: string): Promise<string> {
4444
const shaRe = /^[a-f\d]{40}$/;
4545
if (shaRe.test(actionRef)) {
4646
const octokit = github.getOctokit(process.env.TOKEN || "");
47-
const { data: releases } = await octokit.request(
48-
"GET /repos/{repository}/releases",
47+
const { data: tags } = await octokit.request(
48+
"GET /repos/{owner}/{repository}/tags",
4949
{
50-
repository: process.env.REPOSITORY,
50+
owner: "slsa-framework",
51+
repository: "slsa-verifier",
5152
}
5253
);
53-
for (const release of releases) {
54-
const { data: commit } = await octokit.request(
55-
"GET /reps/{repository}/git/ref/tags/{tagName}",
56-
{
57-
repository: process.env.REPOSITORY,
58-
tagName: release.tag_name,
59-
}
60-
);
61-
const commitSha = commit.object.sha;
54+
for (const tag of tags) {
55+
const commitSha = tag.commit.sha;
6256
if (commitSha === actionRef) {
63-
return release.tag_name;
57+
return tag.name;
6458
}
6559
}
6660
}

0 commit comments

Comments
 (0)