astraproxy/.github/workflows/docker-ci.yml

104 lines
2.9 KiB
YAML
Raw Permalink Normal View History

name: docker-ci
on:
push:
2023-10-07 19:25:14 +02:00
tags:
- 'v*.*.*'
2024-02-11 20:17:09 +01:00
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
2024-02-11 21:15:22 +01:00
DOCKER_BUILDKIT: 1
2024-02-11 20:17:09 +01:00
jobs:
2024-02-11 20:17:09 +01:00
build-and-push-image:
runs-on: ubuntu-latest
2024-02-11 20:17:09 +01:00
permissions:
contents: read
packages: write
steps:
2021-06-09 15:02:05 +02:00
-
name: Checkout
2023-10-07 19:25:14 +02:00
uses: actions/checkout@v4
2021-06-09 15:02:05 +02:00
with:
fetch-depth: 0
-
name: Find Git Tag
id: tagger
2021-06-09 16:23:50 +02:00
uses: jimschubert/query-tag-action@v2
2021-06-09 15:02:05 +02:00
with:
include: 'v*'
exclude: '*-rc*'
2021-06-09 16:33:45 +02:00
commit-ish: 'HEAD'
2021-06-09 15:02:05 +02:00
skip-unshallow: 'true'
2021-06-09 16:23:50 +02:00
abbrev: 7
2024-02-11 21:15:22 +01:00
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Docker scratch meta
id: scratch_meta
2023-10-07 19:25:14 +02:00
uses: docker/metadata-action@v5
with:
2023-10-07 19:25:14 +02:00
# list of Docker images to use as base name for tags
images: |
2024-02-11 20:17:09 +01:00
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
2023-10-07 19:25:14 +02:00
# generate Docker tags based on the following events/attributes
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
-
2024-02-11 21:15:22 +01:00
name: Build and push scratch image
2024-02-11 21:21:01 +01:00
id: docker_build_scratch
2024-02-11 21:15:22 +01:00
uses: docker/build-push-action@v5
with:
context: .
target: scratch
platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7
push: true
tags: ${{ steps.scratch_meta.outputs.tags }}
labels: ${{ steps.scratch_meta.outputs.labels }}
build-args: 'GIT_DESC=${{steps.tagger.outputs.tag}}'
-
2024-02-11 21:15:22 +01:00
name: Docker alpine meta
id: alpine_meta
uses: docker/metadata-action@v5
with:
2024-02-11 21:15:22 +01:00
# list of Docker images to use as base name for tags
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
2024-02-11 21:29:32 +01:00
flavor: |
suffix=-alpine,onlatest=true
2024-02-11 21:15:22 +01:00
tags: |
2024-02-11 21:29:32 +01:00
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
-
2024-02-11 21:15:22 +01:00
name: Build and push alpine image
2024-02-11 21:21:01 +01:00
id: docker_build_alpine
2023-10-07 19:25:14 +02:00
uses: docker/build-push-action@v5
with:
2021-06-09 16:32:46 +02:00
context: .
2024-02-11 21:15:22 +01:00
target: alpine
platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7
push: true
2024-02-11 21:15:22 +01:00
tags: ${{ steps.alpine_meta.outputs.tags }}
labels: ${{ steps.alpine_meta.outputs.labels }}
2023-10-07 19:25:14 +02:00
build-args: 'GIT_DESC=${{steps.tagger.outputs.tag}}'