Merge pull request #262 from pathob/feature/ubuntu-image-push-and-workflow-refactoring
Refactor 'images' workflow, include Ubuntu image to push
This commit is contained in:
commit
211b8efebb
|
|
@ -1,38 +0,0 @@
|
||||||
name: "Setup Docker"
|
|
||||||
|
|
||||||
outputs:
|
|
||||||
sha_short:
|
|
||||||
description: "The short SHA used for image builds"
|
|
||||||
value: ${{ steps.vars.outputs.sha_short }}
|
|
||||||
tag:
|
|
||||||
description: "The tag if run against a tag, otherwise 'canary'"
|
|
||||||
value: ${{ steps.vars.outputs.tag }}
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: "composite"
|
|
||||||
steps:
|
|
||||||
- name: Get Short SHA & Tag
|
|
||||||
id: vars
|
|
||||||
run: |
|
|
||||||
echo ::set-output name=sha_short::${GITHUB_SHA::7}
|
|
||||||
TAG=${GITHUB_REF##*/}
|
|
||||||
if [ "main" == "${TAG}" ]; then
|
|
||||||
TAG=canary
|
|
||||||
fi
|
|
||||||
echo ::set-output name=tag::${TAG:-canary}
|
|
||||||
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 }}
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
name: "Setup Image Variables"
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
dockerfile:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
tag:
|
||||||
|
description: "The tag if run against a tag, otherwise 'canary'"
|
||||||
|
value: ${{ steps.vars.outputs.tag }}
|
||||||
|
suffix:
|
||||||
|
description: "The suffix for the image package name (if any)"
|
||||||
|
value: ${{ steps.vars.outputs.suffix }}
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Get reference and suffix
|
||||||
|
id: vars
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
DOCKERFILE: ${{ inputs.dockerfile }}
|
||||||
|
run: |
|
||||||
|
TAG=${GITHUB_REF##*/}
|
||||||
|
if [[ $GITHUB_REF == refs/heads/main ]]; then
|
||||||
|
TAG=canary
|
||||||
|
elif [[ $GITHUB_REF == refs/pull/*/merge ]]; then
|
||||||
|
TAG=pullrequest # this 'tag' is just used for caching
|
||||||
|
fi
|
||||||
|
echo ::set-output name=tag::${TAG:-canary}
|
||||||
|
SUFFIX=${DOCKERFILE##Dockerfile}
|
||||||
|
if [[ "${SUFFIX}" == "."* ]]; then
|
||||||
|
SUFFIX=${SUFFIX//./-} # convert dots into dashes
|
||||||
|
fi
|
||||||
|
echo ::set-output name=suffix::${SUFFIX}
|
||||||
|
|
@ -22,18 +22,18 @@ on:
|
||||||
- "Makefile"
|
- "Makefile"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-test:
|
build:
|
||||||
if: startsWith(github.ref, 'refs/pull/')
|
name: Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
name: Build
|
packages: write
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
dockerfile:
|
||||||
- dockerfile: Dockerfile
|
- Dockerfile
|
||||||
- dockerfile: Dockerfile.debian
|
- Dockerfile.debian-stable-slim
|
||||||
- dockerfile: Dockerfile.ubuntu
|
- Dockerfile.ubuntu
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
@ -43,29 +43,14 @@ jobs:
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
- name: Build
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
with:
|
||||||
file: ${{ matrix.dockerfile }}
|
version: latest
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
|
|
||||||
build:
|
- name: Set up Image Variables
|
||||||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: write
|
|
||||||
name: Build and Publish
|
|
||||||
env:
|
|
||||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USER }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Setup Docker Environment
|
|
||||||
id: vars
|
id: vars
|
||||||
uses: ./.github/actions/setup-docker-environment
|
uses: ./.github/actions/setup-image-vars
|
||||||
|
with:
|
||||||
|
dockerfile: ${{ matrix.dockerfile }}
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
|
|
@ -74,24 +59,13 @@ jobs:
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and Push
|
- name: Build / Push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
file: Dockerfile
|
file: ${{ matrix.dockerfile }}
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
|
||||||
tags: |
|
tags: |
|
||||||
ghcr.io/${{ github.repository }}:${{ steps.vars.outputs.tag }}
|
ghcr.io/${{ github.repository }}${{ steps.vars.outputs.suffix }}:${{ steps.vars.outputs.tag }}
|
||||||
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:${{ steps.vars.outputs.tag }}
|
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue