Skip to content

Commit 7500601

Browse files
Merge pull request #1100 from justcallmekoko/develop
Fix nightly build release condition
2 parents 9f83e7b + f94d1fd commit 7500601

File tree

1 file changed

+32
-18
lines changed

1 file changed

+32
-18
lines changed

.github/workflows/nightly_build.yml

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,43 @@ jobs:
2626
const owner = context.repo.owner;
2727
const repo = context.repo.repo;
2828
29-
// Find default branch and its HEAD
29+
// Get default branch info
3030
const repoInfo = await github.rest.repos.get({ owner, repo });
3131
const defaultBranch = repoInfo.data.default_branch;
32-
const head = await github.rest.repos.getBranch({ owner, repo, branch: defaultBranch });
32+
33+
const head = await github.rest.repos.getBranch({
34+
owner,
35+
repo,
36+
branch: defaultBranch
37+
});
38+
3339
const headSha = head.data.commit.sha;
34-
const shortSha = headSha.slice(0,7);
40+
const shortSha = headSha.slice(0, 7);
3541
36-
// Try get the existing nightly release (single static tag)
37-
let nightlyRelease = null;
38-
try {
39-
nightlyRelease = await github.rest.repos.getReleaseByTag({
40-
owner, repo, tag: 'nightly'
41-
});
42-
} catch (e) {
43-
if (e.status !== 404) throw e;
42+
// List releases and find the most recent "<sha>_nightly"
43+
const releases = await github.rest.repos.listReleases({
44+
owner,
45+
repo,
46+
per_page: 50
47+
});
48+
49+
let latestNightlySha = null;
50+
51+
for (const rel of releases.data) {
52+
const name = rel.name || "";
53+
54+
const match = name.match(/^([0-9a-f]{7})_nightly$/i);
55+
if (match) {
56+
latestNightlySha = match[1];
57+
break; // releases are returned newest-first
58+
}
4459
}
4560
46-
// Decide if we need to rebuild: compare short SHA in the release name
47-
// Name format we set: "<shortsha>_nightly"
4861
let shouldBuild = true;
49-
if (nightlyRelease) {
50-
const name = nightlyRelease.data.name || '';
51-
const m = name.match(/^([0-9a-f]{7})_nightly$/i);
52-
if (m && m[1] === shortSha) {
53-
shouldBuild = false; // no new commits since last nightly
62+
63+
if (latestNightlySha) {
64+
if (latestNightlySha === shortSha) {
65+
shouldBuild = false;
5466
}
5567
}
5668
@@ -62,6 +74,8 @@ jobs:
6274
compile_sketch:
6375
name: build ${{ matrix.board.name }}
6476
runs-on: ubuntu-latest
77+
needs: decide
78+
if: ${{ needs.decide.outputs.should_build == 'true' }}
6579
strategy:
6680
fail-fast: false
6781
matrix:

0 commit comments

Comments
 (0)