Skip to content

chore: update build action #87

chore: update build action

chore: update build action #87

name: build-and-push-stable-image
on:
push:
tags:
# Match stable and rc versions, such as 'v1.0.0' or 'v0.23.0-rc.0'
- "v*.*.*"
- "v*.*.*-rc.*"
jobs:
build-and-push-stable-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Extract build args
# Extract version number and check if it's an rc version
run: |
if [[ "${GITHUB_REF_NAME}" =~ -rc ]]; then
echo "PRE_RELEASE=true" >> $GITHUB_ENV
else
echo "PRE_RELEASE=false" >> $GITHUB_ENV
fi
echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: yourselfhosted
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
install: true
version: v0.9.1
# Metadata for stable versions
- name: Docker meta for stable
id: meta-stable
if: env.PRE_RELEASE == 'false'
uses: docker/metadata-action@v5
with:
images: |
yourselfhosted/slash
tags: |
type=semver,pattern={{version}},value=${{ env.VERSION }}
type=raw,value=stable
flavor: |
latest=true
labels: |
org.opencontainers.image.version=${{ env.VERSION }}
# Metadata for rc versions
- name: Docker meta for rc
id: meta-rc
if: env.PRE_RELEASE == 'true'
uses: docker/metadata-action@v5
with:
images: |
yourselfhosted/slash
tags: |
type=raw,value=${{ env.VERSION }}
labels: |
org.opencontainers.image.version=${{ env.VERSION }}
- name: Build and Push
id: docker_build
uses: docker/build-push-action@v6
with:
context: ./
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta-stable.outputs.tags || steps.meta-rc.outputs.tags }}
labels: ${{ steps.meta-stable.outputs.labels || steps.meta-rc.outputs.labels }}