Skip to content

Commit 94aa584

Browse files
committed
ci: upload sci_usi artifact on dev build
1 parent 60a4b13 commit 94aa584

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed

.github/workflows/dev.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ jobs:
2121
with:
2222
submodules: recursive
2323

24-
- name: use VERSION file to support dev build on rel-branch
24+
- name: Derive version
2525
id: version
26-
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_OUTPUT
26+
run: |
27+
if [ "${{ github.event_name }}" = "pull_request" ]; then
28+
echo "VERSION=today" >> $GITHUB_OUTPUT
29+
else
30+
echo "VERSION=$(cat VERSION)" >> $GITHUB_OUTPUT
31+
fi
32+
2733
build:
2834
needs: [set_version]
2935
uses: gardenlinux/gardenlinux/.github/workflows/build.yml@3b5ec77e4873462d56658c4ecd56caa0ff63542b
@@ -39,3 +45,30 @@ jobs:
3945
# aws_kms_role: ${{ secrets.KMS_SIGNING_IAM_ROLE }}
4046
# aws_oidc_session: ${{ secrets.AWS_OIDC_SESSION }}
4147
# secureboot_db_kms_arn: ${{ secrets.SECUREBOOT_DB_KMS_ARN }}
48+
49+
meta:
50+
name: Compute image metadata
51+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.action != 'closed' }}
52+
runs-on: ubuntu-latest
53+
outputs:
54+
UPLOAD_VERSION: ${{ steps.meta.outputs.upload_version }}
55+
steps:
56+
- name: Derive image version (pr-123-HASH)
57+
id: meta
58+
run: |
59+
PR_NUMBER=${{ github.event.pull_request.number }}
60+
COMMIT_HASH=${{ github.event.pull_request.head.sha }}
61+
UPLOAD_VERSION="pr-${PR_NUMBER}-${COMMIT_HASH}"
62+
echo "upload_version=${UPLOAD_VERSION}" >> $GITHUB_OUTPUT
63+
64+
upload:
65+
name: Upload PR image to OCI
66+
needs: [build, meta, set_version]
67+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.action != 'closed' }}
68+
uses: ./.github/workflows/upload_oci.yml
69+
with:
70+
version: ${{ needs.set_version.outputs.VERSION }}
71+
upload_version: ${{ needs.meta.outputs.UPLOAD_VERSION }}
72+
flavor_filter: '--include-only "metal-sci_usi-amd64"'
73+
additional_semver_tag: false
74+
secrets: inherit

.github/workflows/upload_oci.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@ on:
55
version:
66
type: string
77
default: today
8+
upload_version:
9+
type: string
10+
default: ""
11+
additional_semver_tag:
12+
type: boolean
13+
default: true
14+
flavor_filter:
15+
type: string
16+
default: '--exclude "bare-*"'
817
jobs:
918
generate_matrix_publish:
1019
name: Generate flavors matrix to publish
1120
uses: gardenlinux/gardenlinux/.github/workflows/build_flavors_matrix.yml@3b5ec77e4873462d56658c4ecd56caa0ff63542b
1221
with:
13-
flags: '--exclude "bare-*" --no-arch --json-by-arch --build --test'
22+
flags: '${{ inputs.flavor_filter }} --no-arch --json-by-arch --build --test'
1423
upload_gl_artifacts:
1524
name: upload to OCI
1625
needs: [ generate_matrix_publish ]
@@ -62,17 +71,19 @@ jobs:
6271
--dir "${CNAME}" \
6372
--container "ghcr.io/${{ github.repository }}" \
6473
--arch ${{ matrix.arch }} \
65-
--version ${{ inputs.version }} \
74+
--version ${{ inputs.upload_version || inputs.version }} \
6675
--cname "${CNAME}" \
6776
--cosign_file digest.txt \
6877
--manifest_file "oci_manifest_entry_${CNAME}.json"
6978
- name: Add additional semver tag
79+
if: ${{ inputs.additional_semver_tag }}
7080
run: |
7181
echo ${{ secrets.GITHUB_TOKEN }} | oras login -u ${{ github.repository_owner }} --password-stdin ghcr.io
82+
UPLOAD_VER="${{ inputs.upload_version || inputs.version }}"
7283
CNAME2=${CNAME//_/-}
7384
CNAME2=${CNAME2//-${{ inputs.version }}/}
74-
echo "Adding additional tag: ${{ inputs.version }}-${CNAME2}-${{ matrix.arch }}"
75-
oras tag ghcr.io/${{ github.repository }}:${{ inputs.version }}-${CNAME}-${{ matrix.arch }} ${{ inputs.version }}-${CNAME2}-${{ matrix.arch }}
85+
echo "Adding additional tag: ${UPLOAD_VER}-${CNAME2}-${{ matrix.arch }}"
86+
oras tag ghcr.io/${{ github.repository }}:${UPLOAD_VER}-${CNAME}-${{ matrix.arch }} ${UPLOAD_VER}-${CNAME2}-${{ matrix.arch }}
7687
- uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # [email protected]
7788
with:
7889
path: oci_manifest_entry_${{ env.CNAME }}.json
@@ -125,5 +136,5 @@ jobs:
125136
126137
gl-oci update-index \
127138
--container "ghcr.io/${{ github.repository }}" \
128-
--version ${{ inputs.version }} \
139+
--version ${{ inputs.upload_version || inputs.version }} \
129140
--manifest_folder manifests

0 commit comments

Comments
 (0)