-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: container-multi-arch-manifest action (#1161)
- Loading branch information
1 parent
c775bba
commit 0574689
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
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,41 @@ | ||
# Create multi arch manifest | ||
|
||
A action to create a multi arch manifest. | ||
|
||
## Example | ||
|
||
```yml | ||
name: Create multi arch manifest | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Create multi arch manifest | ||
uses: greenbone/actions/container-multi-arch-manifest@v3 | ||
with: | ||
tags: | | ||
${{ needs.build-amd64.outputs.tags }} | ||
${{ needs.build-arm64.outputs.tags }} | ||
digests: | | ||
${{ needs.build-amd64.outputs.digest }} | ||
${{ needs.build-arm64.outputs.digest }} | ||
url: ${{ inputs.image-url }} | ||
registry: ${{ secrets.REGISTRY }} | ||
registry-username: ${{ secrets.REGISTRY_USER }} | ||
registry-password: ${{ secrets.REGISTRY_TOKEN }} | ||
``` | ||
|
||
## Inputs | ||
|
||
| Name | Description | | | ||
|-------------------|----------------------------------------------------------------|----------| | ||
| tags | New line seperated multi-arch tag list. | Required | | ||
| digests | New line seperated container image digest list. | Required | | ||
| url | Image url/name without registry. Default is github.repository. | Required | | ||
| registry | Login registry username. | Required | | ||
| registry-username | Login registry username. | Required | | ||
| registry-password | Login registry password. | Required | |
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,60 @@ | ||
name: Container multi-arch image | ||
description: Create a multi-arch image. | ||
|
||
inputs: | ||
tags: | ||
description: "New line seperated multi-arch tag list." | ||
required: true | ||
digests: | ||
description: "New line seperated container image digest list." | ||
required: true | ||
url: | ||
description: "Image url/name without registry. Default is github.repository." | ||
required: true | ||
registry: | ||
description: "Registry url." | ||
required: true | ||
registry-username: | ||
description: "Login registry username." | ||
required: true | ||
registry-password: | ||
description: "Login registry password." | ||
required: true | ||
|
||
branding: | ||
icon: "package" | ||
color: "green" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Login to docker registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ inputs.registry }} | ||
username: ${{ inputs.registry-username }} | ||
password: ${{ inputs.registry-password }} | ||
|
||
- name: Create multi-arch image | ||
shell: bash | ||
run: | | ||
# Define the image URL | ||
url='${{ inputs.registry}}/${{ inputs.url }}' | ||
# Read tags and digests into arrays | ||
set +e | ||
IFS=$'\n' read -r -d '' -a tags <<< "$(printf '%s\n' '${{ inputs.tags }}' | sort -u)" | ||
IFS=$'\n' read -r -d '' -a digests <<< "$(printf '%s\n' '${{ inputs.digests }}' | sort -u)" | ||
set -e | ||
# Build the array of image urls with digests | ||
images=() | ||
for digest in "${digests[@]}"; do | ||
images+=("$url@$digest") | ||
done | ||
# Loop through the tags and create/push multi arch manifests | ||
for tag in "${tags[@]}"; do | ||
docker manifest create "$url:$tag" ${images[@]} | ||
docker manifest push "$url:$tag" | ||
done |