Skip to content

Commit 1a74349

Browse files
committed
Don't assume trigger sha is last commit
Signed-off-by: Joshua Castle <[email protected]>
1 parent 967de42 commit 1a74349

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
needs: release
5252

5353
steps:
54-
- uses: Kas-tle/release-build-log-action@46873b93db54b63e3d412ff7be96261c3593674c
54+
- uses: Kas-tle/release-build-log-action@1b57448eaf9476e6e05450e4ea240449eac2c0d2
5555
with:
5656
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5757
releaseID: ${{ needs.release.outputs.release_id }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "base-release-action",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "An action to create incremented releases in a similar style to Jenkins",
55
"repository": "https://github.com/Kas-tle/base-release-action.git",
66
"author": "Joshua Castle <[email protected]",

src/action/inputs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ async function getChanges(api: OctokitApi, prevRelease: PreviousRelease, repoDat
119119

120120
if (prevRelease.commit == null) {
121121
if (branch === defaultBranch) {
122-
firstCommit = `${process.env.GITHUB_SHA!}^`;
122+
firstCommit = `${lastCommit}^`;
123123
} else {
124124
const compareReponse = await api.rest.repos.compareCommits({ owner: repoData.owner, repo: repoData.repo, base: defaultBranch, head: branch });
125125
try {
126126
firstCommit = `${compareReponse.data.commits[0].sha}^`;
127127
} catch (error) {
128-
firstCommit = `${process.env.GITHUB_SHA!}^`;
128+
firstCommit = `${lastCommit}^`;
129129
}
130130
}
131131
} else {

src/action/store.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,28 @@ import { Repo } from "../types/repo";
55
import { isDeepStrictEqual } from 'util';
66

77
export async function storeReleaseData(inputs: Inputs, api: OctokitApi, repoData: Repo) {
8-
let updated = await checkStoreReleaseData(inputs, api, repoData);
8+
const lastCommit = inputs.changes[inputs.changes.length - 1].commit;
9+
let updated = await checkStoreReleaseData(inputs, api, repoData, lastCommit);
910

1011
let retries = 0;
1112
while (!updated && retries < 10) {
1213
console.log(`Previous release data not updated, retrying in 5 seconds...`);
1314
await new Promise(resolve => setTimeout(resolve, 5000));
14-
updated = await checkStoreReleaseData(inputs, api, repoData);
15+
updated = await checkStoreReleaseData(inputs, api, repoData, lastCommit);
1516
retries++;
1617

1718
if (retries === 10) {
1819
core.setFailed(`Previous release data not updated after 10 retries`);
1920
}
2021
}
2122

22-
console.log(`Updated previous commit ${process.env.GITHUB_SHA!}`);
23+
console.log(`Updated previous commit ${lastCommit}`);
2324
console.log(`Updated previous base tag to ${inputs.tag.base}`);
2425
}
2526

26-
async function checkStoreReleaseData(inputs: Inputs, api: OctokitApi, repoData: Repo): Promise<boolean> {
27+
async function checkStoreReleaseData(inputs: Inputs, api: OctokitApi, repoData: Repo, lastCommit: string): Promise<boolean> {
2728
const { owner, repo, branch } = repoData;
28-
const newEntry = { c: process.env.GITHUB_SHA!, t: inputs.tag.base };
29+
const newEntry = { c: lastCommit, t: inputs.tag.base };
2930

3031
const variable = 'releaseAction_prevRelease';
3132
const varResponse = await api.rest.actions.getRepoVariable({ owner, repo, name: variable });

0 commit comments

Comments
 (0)