-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
92 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,91 @@ | ||
name: build | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
release: | ||
types: | ||
- created | ||
|
||
env: | ||
IMAGE_OWNER: noenv | ||
IMAGE_NAME: curl | ||
|
||
jobs: | ||
build: | ||
name: Build images | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
arch: [ amd64, arm64 ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install qemu dependency | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y qemu-user-static | ||
- name: Build Image | ||
id: build_image | ||
uses: redhat-actions/buildah-build@v2 | ||
with: | ||
image: ${{ env.IMAGE_NAME }} | ||
tags: ${{ matrix.arch }} | ||
arch: ${{ matrix.arch }} | ||
dockerfiles: | | ||
./Dockerfile | ||
- name: Check images created | ||
run: buildah images | grep '${{ env.IMAGE_NAME }}' | ||
|
||
- name: Check image metadata | ||
run: | | ||
set -x | ||
buildah inspect ${{ steps.build_image.outputs.image }}:${{ matrix.arch }} | jq ".OCIv1.architecture" | ||
buildah inspect ${{ steps.build_image.outputs.image }}:${{ matrix.arch }} | jq ".Docker.architecture" | ||
- name: Export image | ||
run: podman save -o /tmp/image.tar ${{ steps.build_image.outputs.image }}:${{ matrix.arch }} | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: image-${{ matrix.arch }} | ||
path: /tmp/image.tar | ||
|
||
push: | ||
name: Publish images | ||
runs-on: ubuntu-latest | ||
needs: build | ||
environment: production | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v2 | ||
|
||
- name: Import images | ||
run: | | ||
podman load -i ./image-amd64/image.tar | ||
podman load -i ./image-arm64/image.tar | ||
- name: Create multi-arch manifest | ||
run: | | ||
buildah manifest create ${{ env.IMAGE_NAME }}:latest | ||
buildah manifest add --arch amd64 ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:amd64 | ||
buildah manifest add --arch arm64 --variant v8 ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:arm64 | ||
- name: Push unstable images | ||
if: ${{ github.event_name == 'push' }} | ||
run: | | ||
buildah manifest push --all --format v2s2 --creds zyclonite:${{ secrets.REGISTRY_PASSWORD }} ${{ env.IMAGE_NAME }}:latest docker://docker.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:main | ||
- name: Push stable images | ||
if: ${{ github.event_name == 'release' }} | ||
run: | | ||
buildah manifest push --all --format v2s2 --creds zyclonite:${{ secrets.REGISTRY_PASSWORD }} ${{ env.IMAGE_NAME }}:latest docker://docker.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:latest | ||
buildah manifest push --all --format v2s2 --creds zyclonite:${{ secrets.REGISTRY_PASSWORD }} ${{ env.IMAGE_NAME }}:latest docker://docker.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }} |
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