From 09acbf2d118e3f15c1e6e56cfc4d53834e21e782 Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Sun, 3 Apr 2022 06:11:33 +0000 Subject: [PATCH] Publish canary container images via ghcr.io Ref https://github.com/roboll/helmfile/issues/1824 --- .../setup-docker-environment/action.yaml | 30 ++++++++++ .github/workflows/canary_images.yaml | 60 +++++++++++++++++++ Dockerfile | 2 + Dockerfile.debian | 2 + 4 files changed, 94 insertions(+) create mode 100644 .github/actions/setup-docker-environment/action.yaml create mode 100644 .github/workflows/canary_images.yaml diff --git a/.github/actions/setup-docker-environment/action.yaml b/.github/actions/setup-docker-environment/action.yaml new file mode 100644 index 000000000..7712fe27d --- /dev/null +++ b/.github/actions/setup-docker-environment/action.yaml @@ -0,0 +1,30 @@ +name: "Setup Docker" + +outputs: + sha_short: + description: "The short SHA used for image builds" + value: ${{ steps.vars.outputs.sha_short }} + +runs: + using: "composite" + steps: + - name: Get Short SHA + id: vars + run: | + echo ::set-output name=sha_short::${GITHUB_SHA::7} + shell: bash + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + with: + version: latest + + # - name: Login to DockerHub + # if: ${{ github.ref == 'main' && github.event.pull_request.merged == true }} + # uses: docker/login-action@v1 + # with: + # username: ${{ inputs.username }} + # password: ${{ inputs.password }} diff --git a/.github/workflows/canary_images.yaml b/.github/workflows/canary_images.yaml new file mode 100644 index 000000000..89dad365c --- /dev/null +++ b/.github/workflows/canary_images.yaml @@ -0,0 +1,60 @@ +name: Publish Canary Images + +on: + push: + branches: + - main + paths-ignore: + - .github/workflows/ci.yml + - .github/workflows/lock.yml + - "docs/**" + - "hack/**" + - "**.md" + - ".gitignore" + - "Makefile" + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + name: Build and Publish Canary Images + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USER }} + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Docker Environment + id: vars + uses: ./.github/actions/setup-docker-environment + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and Push + uses: docker/build-push-action@v2 + with: + file: Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ghcr.io/${{ github.repository }}:canary + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build and Push (debian stable-slim) + uses: docker/build-push-action@v2 + with: + file: Dockerfile.debian + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ghcr.io/${{ github.repository }}-debian-stable-slim:canary + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index 9b745c748..7d870dd3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,8 @@ RUN make static-linux FROM alpine:3.13 +LABEL org.opencontainers.image.source https://github.com/helmfile/helmfile + RUN apk add --no-cache ca-certificates git bash curl jq ARG HELM_VERSION="v3.7.2" diff --git a/Dockerfile.debian b/Dockerfile.debian index 4d8f91ec2..8ce93271b 100644 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -15,6 +15,8 @@ RUN make static-linux FROM debian:stable-slim +LABEL org.opencontainers.image.source https://github.com/helmfile/helmfile + RUN apt-get update \ && apt-get install -y --no-install-recommends \ ca-certificates \