Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

Commit 3adddf7

Browse files
authored
ci(workflow): enable community contributions (#1848)
* ci: enable community contributions Signed-off-by: Bence Csati <[email protected]> * fix: remarks Signed-off-by: Bence Csati <[email protected]> * fix: improve image build Signed-off-by: Bence Csati <[email protected]> * feat: add manual build-and-push workflow Signed-off-by: Bence Csati <[email protected]> --------- Signed-off-by: Bence Csati <[email protected]>
1 parent c766ebe commit 3adddf7

16 files changed

+303
-560
lines changed

.github/workflows/build-and-push-component.yaml

-168
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Build and Push Components Manual
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
packages: write
8+
9+
jobs:
10+
build-and-push:
11+
uses: ./.github/workflows/build-and-push-components-registry.yml
12+
with:
13+
suffix: "-dev"
14+
image_tag: latest
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Build and Push Components Registry
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
image_tag:
7+
required: true
8+
type: string
9+
description: 'Image tag to use.'
10+
registry_name:
11+
required: false
12+
type: string
13+
description: 'Name of the registry.'
14+
default: ghcr.io/openclarity
15+
suffix:
16+
required: false
17+
type: string
18+
description: 'Suffix to append to the image name'
19+
default: ""
20+
bake-group:
21+
required: false
22+
type: string
23+
description: 'Name of the Docker Bake group of targets'
24+
default: default
25+
26+
jobs:
27+
prepare-build:
28+
runs-on: ubuntu-latest
29+
outputs:
30+
timestamp: ${{ steps.timestamp.outputs.timestamp }}
31+
targets: ${{ steps.targets.outputs.targets }}
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
35+
36+
- name: Set timestamp
37+
id: timestamp
38+
run: |
39+
##
40+
## Set timestamp variable
41+
##
42+
43+
echo "timestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT"
44+
45+
- name: List targets
46+
id: targets
47+
uses: docker/bake-action/subaction/list-targets@7a5dfed3550ca014665af2a27af8fc9d7284b9b3 # v4.5.0
48+
with:
49+
target: ${{ inputs.bake-group }}
50+
51+
build-and-push:
52+
needs: prepare-build
53+
runs-on: ubuntu-latest
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
targets: ${{ fromJson(needs.prepare-build.outputs.targets) }}
58+
steps:
59+
- name: Checkout code
60+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
61+
62+
- name: Set up Docker Buildx
63+
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
64+
65+
- name: Cache Docker layers
66+
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
67+
with:
68+
path: /tmp/.buildx-cache
69+
key: ${{ runner.os }}-buildx-${{ github.ref }}
70+
restore-keys: |
71+
${{ runner.os }}-buildx-
72+
73+
- name: Login to GitHub Container Registry
74+
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
75+
with:
76+
registry: ghcr.io
77+
username: ${{ github.actor }}
78+
password: ${{ secrets.GITHUB_TOKEN }}
79+
80+
- name: Build
81+
uses: docker/bake-action@7a5dfed3550ca014665af2a27af8fc9d7284b9b3 # v4.5.0
82+
id: bake
83+
with:
84+
targets: ${{ matrix.targets }}
85+
set: |
86+
*.platform=linux/amd64,linux/arm64
87+
*.output=type=image,name=${{ inputs.registry_name }}/${{ matrix.targets }},name-canonical=true,push=true
88+
*.cache-to=type=local,dest=/tmp/.buildx-cache
89+
*.cache-from=type=local,src=/tmp/.buildx-cache
90+
env:
91+
VERSION: ${{ inputs.image_tag }}
92+
BUILD_TIMESTAMP: ${{ needs.prepare-build.outputs.timestamp }}
93+
COMMIT_HASH: ${{ github.sha }}
94+
DOCKER_REGISTRY: ${{ inputs.registry_name }}
95+
SUFFIX: ${{ inputs.suffix }}
96+
DOCKER_TAG: ${{ inputs.image_tag }}
97+
BUILD_OPTS: -tags=exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Build and Upload Components
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
image_tag:
7+
required: true
8+
type: string
9+
description: 'Image tag to use.'
10+
registry_name:
11+
required: false
12+
type: string
13+
description: 'Name of the registry.'
14+
default: openclarity.io
15+
bake-group:
16+
required: false
17+
type: string
18+
description: 'Name of the Docker Bake group of targets'
19+
default: default
20+
21+
jobs:
22+
prepare-build:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
timestamp: ${{ steps.timestamp.outputs.timestamp }}
26+
targets: ${{ steps.targets.outputs.targets }}
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
30+
31+
- name: Set timestamp
32+
id: timestamp
33+
run: |
34+
##
35+
## Set timestamp variable
36+
##
37+
38+
echo "timestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT"
39+
40+
- name: List targets
41+
id: targets
42+
uses: docker/bake-action/subaction/list-targets@7a5dfed3550ca014665af2a27af8fc9d7284b9b3 # v4.5.0
43+
with:
44+
target: ${{ inputs.bake-group }}
45+
46+
build-and-upload:
47+
needs: prepare-build
48+
runs-on: ubuntu-latest
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
targets: ${{ fromJson(needs.prepare-build.outputs.targets) }}
53+
steps:
54+
- name: Checkout code
55+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
56+
57+
- name: Set up Docker Buildx
58+
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
59+
60+
- name: Cache Docker layers
61+
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
62+
with:
63+
path: /tmp/.buildx-cache
64+
key: ${{ runner.os }}-buildx-${{ github.ref }}
65+
restore-keys: ${{ runner.os }}-buildx-
66+
67+
- name: Build
68+
uses: docker/bake-action@7a5dfed3550ca014665af2a27af8fc9d7284b9b3 # v4.5.0
69+
id: bake
70+
with:
71+
targets: ${{ matrix.targets }}
72+
set: |
73+
*.platform=linux/amd64
74+
*.output=type=docker,dest=/tmp/${{ matrix.targets }}.tar
75+
*.cache-to=type=local,dest=/tmp/.buildx-cache
76+
*.cache-from=type=local,src=/tmp/.buildx-cache
77+
env:
78+
VERSION: ${{ inputs.image_tag }}
79+
BUILD_TIMESTAMP: ${{ needs.prepare-build.outputs.timestamp }}
80+
COMMIT_HASH: ${{ github.sha }}
81+
DOCKER_REGISTRY: ${{ inputs.registry_name }}
82+
DOCKER_TAG: ${{ inputs.image_tag }}
83+
BUILD_OPTS: -tags=exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper
84+
85+
- name: Save artifact
86+
run: |
87+
mkdir -p /tmp/artifacts
88+
mv "/tmp/${{ matrix.targets }}.tar" /tmp/artifacts/
89+
ARTIFACT_NAME="$(echo ${{ matrix.targets }}-${{ inputs.image_tag }} | tr '/' '-')"
90+
echo ARTIFACT_NAME="$ARTIFACT_NAME" >> "$GITHUB_ENV"
91+
92+
- name: Upload artifact
93+
id: upload-artifacts
94+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
95+
with:
96+
name: ${{ env.ARTIFACT_NAME }}
97+
path: /tmp/artifacts/${{ matrix.targets }}.tar
98+
if-no-files-found: error
99+
retention-days: 1
100+
compression-level: 0
101+
overwrite: true

.github/workflows/cache-cleanup.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
2+
name: Cache Cleanup
23

3-
name: Cache cleanup
44
on:
55
pull_request:
66
types:

0 commit comments

Comments
 (0)