Skip to content

Commit

Permalink
use github api to get commit sha from ref
Browse files Browse the repository at this point in the history
  • Loading branch information
crazy-max committed Aug 14, 2024
1 parent 4f3737d commit 8688a64
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
29 changes: 20 additions & 9 deletions .github/workflows/.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: .test
on:
workflow_call:
inputs:
revisions:
refs:
required: true
type: string

Expand All @@ -16,7 +16,7 @@ jobs:
init:
runs-on: ubuntu-24.04
outputs:
revisions: ${{ steps.set.outputs.revisions }}
commits: ${{ steps.set.outputs.commits }}
steps:
-
name: Checkout
Expand All @@ -27,10 +27,19 @@ jobs:
uses: actions/github-script@v7
with:
script: |
await core.group(`Set revisions matrix`, async () => {
const revisions = `${{ inputs.revisions }}`.trim().split(/\r?\n/);
core.info(JSON.stringify(revisions, null, 2));
core.setOutput('revisions', JSON.stringify(revisions));
await core.group(`Set commits matrix`, async () => {
let commits = [];
for (const ref of `${{ inputs.refs }}`.trim().split(/\r?\n/)) {
const commit = github.rest.repos.getCommit({
'moby',
'buildkit',
ref,
});
core.info(`${ref} -> ${commit.data.sha}`);
commits.push(commit.data.sha);
}
core.info(JSON.stringify(commits, null, 2));
core.setOutput('commits', JSON.stringify(commits));
});
prepare:
Expand All @@ -40,7 +49,7 @@ jobs:
strategy:
fail-fast: false
matrix:
revision: ${{ fromJson(needs.init.outputs.revisions) }}
commit: ${{ fromJson(needs.init.outputs.commits) }}
steps:
-
name: Checkout
Expand All @@ -58,5 +67,7 @@ jobs:
with:
targets: tests-base
set: |
buildkit-binaries.cache-from=type=gha,scope=buildkit-${{ matrix.revision }}
buildkit-binaries.cache-to=type=gha,scope=buildkit-${{ matrix.revision }}
buildkit-binaries.cache-from=type=gha,scope=buildkit-${{ matrix.commit }}
buildkit-binaries.cache-to=type=gha,scope=buildkit-${{ matrix.commit }}
env:
BUILDKIT_REF: ${{ matrix.commit }}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: ./.github/workflows/.test.yml
secrets: inherit
with:
revisions: |
refs: |
master
v0.15.1
v0.14.1
4 changes: 2 additions & 2 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ variable "BUILDKIT_REPO" {
default = "moby/buildkit"
}

variable "BUILDKIT_REVISION" {
variable "BUILDKIT_REF" {
default = "master"
}

Expand All @@ -15,7 +15,7 @@ group "default" {
}

target "buildkit-binaries" {
context = "https://github.com/${BUILDKIT_REPO}.git#${BUILDKIT_REVISION}"
context = "https://github.com/${BUILDKIT_REPO}.git#${BUILDKIT_REF}"
target = BUILDKIT_TARGET
args = {
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
Expand Down

0 comments on commit 8688a64

Please sign in to comment.