Skip to content

Commit

Permalink
fix(ci): add a "build-id" input var to ci builds
Browse files Browse the repository at this point in the history
Currently, the github workflows dependencies are chained as follows:

build.yaml -> ci.yaml
release.yaml -> ci.yaml
convert.yaml -> ci.yaml

build.yaml and release.yaml are inline builds but operate on different
build triggers. convert.yaml is timer-based and works offline.

Signed-off-by: Ramkumar Chinchani <[email protected]>
  • Loading branch information
rchincha committed Mar 7, 2023
1 parent d805401 commit 14d01ff
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
required: true
type: string
description: 'Stringified JSON object listing stacker privilege-level'
build-id:
required: true
type: string
description: 'Stringified JSON object listing stacker build-id'
jobs:
build:
runs-on: ubuntu-22.04
Expand All @@ -22,6 +26,7 @@ jobs:
matrix:
go-version: ${{fromJson(inputs.go-version)}}
privilege-level: ${{fromJson(inputs.privilege-level)}}
build-id: ${{fromJson(inputs.build-id)}}
name: "golang ${{ matrix.go-version }} privilege ${{ matrix.privilege-level }}"
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -58,7 +63,7 @@ jobs:
- if: github.event_name == 'release' && github.event.action == 'published'
name: Build and test released version
run: |
make check VERSION_FULL=${{ github.event.release.tag_name }}-${{ steps.short-sha.outputs.sha }} PRIVILEGE_LEVEL=${{ matrix.privilege-level }}
make check VERSION_FULL=${{ matrix.build-id }} PRIVILEGE_LEVEL=${{ matrix.privilege-level }}
env:
REGISTRY_URL: localhost:5000
- name: Upload code coverage
Expand All @@ -67,4 +72,4 @@ jobs:
id: restore-build
with:
path: stacker
key: ${{ steps.short-sha.outputs.sha }}
key: ${{ matrix.build-id }}
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ jobs:
["1.20.x"]
privilege-level: >-
["unpriv", "priv"]
build-id: >-
["${{ github.ref }}"]
13 changes: 1 addition & 12 deletions .github/workflows/convert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,17 @@ env:
REGISTRY_URL: localhost:5000

jobs:
ci:
uses: ./.github/workflows/build.yaml
with:
# note >-, args needs to be strings to be used as inputs
# for the reusable build.yaml workflow
go-version: >-
["1.20.x"]
privilege-level: >-
["priv"]
convert:
name: "convert"
runs-on: ubuntu-20.04
# needs ci for the cached stacker binary
needs: ci
steps:
- uses: benjlevesque/[email protected]
id: short-sha
- uses: actions/cache@v3
id: restore-build
with:
path: stacker
key: ${{ steps.short-sha.outputs.sha }}
key: ${{ github.ref }}
- name: zot registry
env:
ZOT_HOST: localhost
Expand Down
19 changes: 15 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,39 @@ on:
- published

jobs:
build-id:
runs-on: ubuntu-latest
outputs:
build-id: ${{steps.build-id.outputs.build-id}}
steps:
- uses: actions/checkout@v3
- uses: benjlevesque/[email protected]
id: short-sha
- id: build-id
run: echo "build-id=${{ github.event.release.tag_name }}-${{ steps.short-sha.outputs.sha }}" >> "$GITHUB_OUTPUT"
ci:
uses: ./.github/workflows/build.yaml
needs: build-id
with:
# note >-, args needs to be strings to be used as inputs
# for the reusable build.yaml workflow
go-version: >-
["1.20.x"]
privilege-level: >-
["priv"]
build-id: >-
["${{needs.build-id.outputs.build-id}}"]
release:
name: "Tagged Release"
runs-on: ubuntu-20.04
# needs ci for the cached stacker binary
needs: ci
needs: [build-id, ci]
steps:
- uses: benjlevesque/[email protected]
id: short-sha
- uses: actions/cache@v3
id: restore-build
with:
path: stacker
key: ${{ steps.short-sha.outputs.sha }}
key: ${{needs.build-id.outputs.build-id}}
- if: github.event_name == 'release' && github.event.action == 'published'
name: Publish artifacts on releases
uses: svenstaro/upload-release-action@v2
Expand Down

0 comments on commit 14d01ff

Please sign in to comment.