Skip to content

Publish

Publish #221

Workflow file for this run

---
name: Publish
on:
push:
branches:
- master
- mainline
- rb/*
workflow_dispatch: # Allow manual trigger for automated rebuilds
env:
IMAGE_NAME: fholzer/nginx-brotli
jobs:
build-test-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Extract Version
id: get_version
run: |
# Extract value
VERSION=$(grep "^ARG NGINX_VERSION=" Dockerfile | head -1 | cut -d= -f2)
FULL_VERSION="v$VERSION"
MAJOR_MINOR=$(echo "$VERSION" | cut -d. -f1-2)
MAJOR_MINOR_VERSION="v$MAJOR_MINOR"
# get versions from master and mainline
MASTER_VERSION=$(git show master:Dockerfile | grep "^ARG NGINX_VERSION=" | head -1 | cut -d= -f2)
MAINLINE_VERSION=$(git show master:Dockerfile | grep "^ARG NGINX_VERSION=" | head -1 | cut -d= -f2)
ALL_VERSIONS=$(git branch -ar --format "%(refname)" | grep "rb/v" | sed -e 's@^.*/rb/v@@')
ALL_VERSIONS="$ALL_VERSIONS"$'\n'"$MASTER_VERSION"$'\n'"$MAINLINE_VERSION"
LATEST_PATCH=$(echo "$ALL_VERSIONS" | grep "^$MAJOR_MINOR" | sort -V | tail -n 1)
# Export to the output file
echo "nginx_full_version=$FULL_VERSION" >> $GITHUB_OUTPUT
echo "nginx_major_minor=$MAJOR_MINOR_VERSION" >> $GITHUB_OUTPUT
echo "nginx_latest_patch=$LATEST_PATCH" >> $GITHUB_OUTPUT
- name: Docker meta
id: meta
uses: docker/metadata-action@v6.0.0
with:
images: ${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=raw,priority=1000,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=raw,priority=1000,value=mainline-latest,enable=${{ github.ref == 'refs/heads/mainline' }}
type=raw,value=${{ steps.get_version.outputs.nginx_full_version }}
type=raw,value=${{ steps.get_version.outputs.nginx_major_minor }},enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || github.ref == 'refs/heads/mainline' || github.ref == format('refs/heads/rb/v{0}', steps.get_version.outputs.nginx_latest_patch) }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4.0.0
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v4.0.0
- name: Build amd64 image
uses: docker/build-push-action@v7.1.0
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
platforms: linux/amd64
push: false
tags: ${{ steps.meta.outputs.tags }}
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: List images
run: |
docker images
- name: Test
run: |
docker run --rm -v $(pwd)/tests.sh:/tests.sh --entrypoint sh ${{ env.IMAGE_NAME }} /tests.sh
- name: Login to Docker Hub
uses: docker/login-action@v4
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and publish multi-platform images
uses: docker/build-push-action@v7.1.0
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
platforms: linux/amd64,linux/arm64,linux/ppc64le
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max