This repository has been archived by the owner on Oct 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
Showing
16 changed files
with
303 additions
and
560 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Build and Push Components Manual | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
packages: write | ||
|
||
jobs: | ||
build-and-push: | ||
uses: ./.github/workflows/build-and-push-components-registry.yml | ||
with: | ||
suffix: "-dev" | ||
image_tag: latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: Build and Push Components Registry | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
image_tag: | ||
required: true | ||
type: string | ||
description: 'Image tag to use.' | ||
registry_name: | ||
required: false | ||
type: string | ||
description: 'Name of the registry.' | ||
default: ghcr.io/openclarity | ||
suffix: | ||
required: false | ||
type: string | ||
description: 'Suffix to append to the image name' | ||
default: "" | ||
bake-group: | ||
required: false | ||
type: string | ||
description: 'Name of the Docker Bake group of targets' | ||
default: default | ||
|
||
jobs: | ||
prepare-build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
timestamp: ${{ steps.timestamp.outputs.timestamp }} | ||
targets: ${{ steps.targets.outputs.targets }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
|
||
- name: Set timestamp | ||
id: timestamp | ||
run: | | ||
## | ||
## Set timestamp variable | ||
## | ||
echo "timestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT" | ||
- name: List targets | ||
id: targets | ||
uses: docker/bake-action/subaction/list-targets@7a5dfed3550ca014665af2a27af8fc9d7284b9b3 # v4.5.0 | ||
with: | ||
target: ${{ inputs.bake-group }} | ||
|
||
build-and-push: | ||
needs: prepare-build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
targets: ${{ fromJson(needs.prepare-build.outputs.targets) }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.ref }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build | ||
uses: docker/bake-action@7a5dfed3550ca014665af2a27af8fc9d7284b9b3 # v4.5.0 | ||
id: bake | ||
with: | ||
targets: ${{ matrix.targets }} | ||
set: | | ||
*.platform=linux/amd64,linux/arm64 | ||
*.output=type=image,name=${{ inputs.registry_name }}/${{ matrix.targets }},name-canonical=true,push=true | ||
*.cache-to=type=local,dest=/tmp/.buildx-cache | ||
*.cache-from=type=local,src=/tmp/.buildx-cache | ||
env: | ||
VERSION: ${{ inputs.image_tag }} | ||
BUILD_TIMESTAMP: ${{ needs.prepare-build.outputs.timestamp }} | ||
COMMIT_HASH: ${{ github.sha }} | ||
DOCKER_REGISTRY: ${{ inputs.registry_name }} | ||
SUFFIX: ${{ inputs.suffix }} | ||
DOCKER_TAG: ${{ inputs.image_tag }} | ||
BUILD_OPTS: -tags=exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: Build and Upload Components | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
image_tag: | ||
required: true | ||
type: string | ||
description: 'Image tag to use.' | ||
registry_name: | ||
required: false | ||
type: string | ||
description: 'Name of the registry.' | ||
default: openclarity.io | ||
bake-group: | ||
required: false | ||
type: string | ||
description: 'Name of the Docker Bake group of targets' | ||
default: default | ||
|
||
jobs: | ||
prepare-build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
timestamp: ${{ steps.timestamp.outputs.timestamp }} | ||
targets: ${{ steps.targets.outputs.targets }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
|
||
- name: Set timestamp | ||
id: timestamp | ||
run: | | ||
## | ||
## Set timestamp variable | ||
## | ||
echo "timestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT" | ||
- name: List targets | ||
id: targets | ||
uses: docker/bake-action/subaction/list-targets@7a5dfed3550ca014665af2a27af8fc9d7284b9b3 # v4.5.0 | ||
with: | ||
target: ${{ inputs.bake-group }} | ||
|
||
build-and-upload: | ||
needs: prepare-build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
targets: ${{ fromJson(needs.prepare-build.outputs.targets) }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.ref }} | ||
restore-keys: ${{ runner.os }}-buildx- | ||
|
||
- name: Build | ||
uses: docker/bake-action@7a5dfed3550ca014665af2a27af8fc9d7284b9b3 # v4.5.0 | ||
id: bake | ||
with: | ||
targets: ${{ matrix.targets }} | ||
set: | | ||
*.platform=linux/amd64 | ||
*.output=type=docker,dest=/tmp/${{ matrix.targets }}.tar | ||
*.cache-to=type=local,dest=/tmp/.buildx-cache | ||
*.cache-from=type=local,src=/tmp/.buildx-cache | ||
env: | ||
VERSION: ${{ inputs.image_tag }} | ||
BUILD_TIMESTAMP: ${{ needs.prepare-build.outputs.timestamp }} | ||
COMMIT_HASH: ${{ github.sha }} | ||
DOCKER_REGISTRY: ${{ inputs.registry_name }} | ||
DOCKER_TAG: ${{ inputs.image_tag }} | ||
BUILD_OPTS: -tags=exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper | ||
|
||
- name: Save artifact | ||
run: | | ||
mkdir -p /tmp/artifacts | ||
mv "/tmp/${{ matrix.targets }}.tar" /tmp/artifacts/ | ||
ARTIFACT_NAME="$(echo ${{ matrix.targets }}-${{ inputs.image_tag }} | tr '/' '-')" | ||
echo ARTIFACT_NAME="$ARTIFACT_NAME" >> "$GITHUB_ENV" | ||
- name: Upload artifact | ||
id: upload-artifacts | ||
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | ||
with: | ||
name: ${{ env.ARTIFACT_NAME }} | ||
path: /tmp/artifacts/${{ matrix.targets }}.tar | ||
if-no-files-found: error | ||
retention-days: 1 | ||
compression-level: 0 | ||
overwrite: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.