Skip to content

build

build #51

Workflow file for this run

name: build
on:
workflow_dispatch:
schedule:
- cron: '0 0 1 * *'
push:
branches:
- 'main'
tags:
- '*'
paths-ignore:
- '**.md'
pull_request:
branches:
- 'main'
paths-ignore:
- '**.md'
env:
DOCKERHUB_SLUG: imoize/alpine-s6
GHCR_SLUG: ghcr.io/imoize/alpine-s6
ALPINE_LATEST: 3.21
jobs:
build:
strategy:
fail-fast: false
matrix:
alpine_version:
- 'edge'
- '3.20'
- '3.21'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Preparation
id: prep
run: |
ALPINE_VERSION="${{ matrix.alpine_version }}"
ALPINE_RELEASE=$ALPINE_VERSION
if [[ "$ALPINE_VERSION" != "edge" ]]; then
ALPINE_RELEASE="v$ALPINE_VERSION"
fi
IMAGE_VERSION=$(curl -s "https://api.github.com/repos/${{ github.repository }}/tags" | jq -r '.[0].name')
LATEST=""
if [ "$ALPINE_VERSION" = "${{ env.ALPINE_LATEST }}" ]; then
LATEST="true"
else
LATEST="false"
fi
echo "image_version=$IMAGE_VERSION" >> "$GITHUB_OUTPUT"
echo "alpine_version=$ALPINE_VERSION" >> "$GITHUB_OUTPUT"
echo "alpine_release=$ALPINE_RELEASE" >> "$GITHUB_OUTPUT"
echo "latest=$LATEST" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DOCKERHUB
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract Docker Metadata
id: meta
uses: docker/metadata-action@v5
with:
flavor: latest=${{ steps.prep.outputs.latest }}
images: |
${{ env.GHCR_SLUG }}
${{ env.DOCKERHUB_SLUG }}
labels: |
maintainer=Imoize
org.opencontainers.image.vendor=Imoize
org.opencontainers.image.title=alpine-s6
org.opencontainers.image.version=${{ steps.prep.outputs.image_version }}
tags: |
${{ steps.prep.outputs.alpine_version }}
- name: Build and Push Docker Image
if: ${{ github.event_name != 'pull_request' }}
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
build-args: |
ALPINE_VERSION=${{ steps.prep.outputs.alpine_version }}
ALPINE_RELEASE=${{ steps.prep.outputs.alpine_release }}
push: ${{ github.event_name != 'pull_request' }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
- name: Docker Hub Description
if: github.event_name != 'pull_request'
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ env.DOCKERHUB_SLUG }}
short-description: ${{ github.event.repository.description }}
- name: Check Manifest
if: github.event_name != 'pull_request'
run: |
docker buildx imagetools inspect ${{ env.DOCKERHUB_SLUG }}:${{ steps.prep.outputs.alpine_version }}
docker buildx imagetools inspect ${{ env.GHCR_SLUG }}:${{ steps.prep.outputs.alpine_version }}
- name: Check Pull
if: github.event_name != 'pull_request'
run: |
docker pull ${{ env.DOCKERHUB_SLUG }}:${{ steps.prep.outputs.alpine_version }}
docker image inspect ${{ env.DOCKERHUB_SLUG }}:${{ steps.prep.outputs.alpine_version }}
docker pull ${{ env.GHCR_SLUG }}:${{ steps.prep.outputs.alpine_version }}
docker image inspect ${{ env.GHCR_SLUG }}:${{ steps.prep.outputs.alpine_version }}