caddy-release #75
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Standard Docker Image | |
on: | |
repository_dispatch: | |
types: [caddy-release] | |
workflow_dispatch: | |
inputs: | |
build_version: | |
description: 'Caddy version to build (without v prefix, e.g., 2.8.0)' | |
required: false | |
permissions: | |
contents: write | |
packages: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Convert Repository Owner to Lowercase | |
run: | | |
REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]') | |
echo "REPO_OWNER=${REPO_OWNER}" >> $GITHUB_ENV | |
- name: Set version | |
id: set_version | |
run: | | |
# Get version from input or payload | |
VERSION="${{ github.event.inputs.build_version || github.event.client_payload.caddy_version }}" | |
# Exit if no version specified | |
if [ -z "$VERSION" ]; then | |
echo "No version specified. Exiting." | |
exit 1 | |
fi | |
# Strip v prefix if present | |
VERSION="${VERSION#v}" | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Docker Metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/${{ env.REPO_OWNER }}/caddy-cloudflare | |
${{ secrets.DOCKERHUB_USERNAME }}/caddy-cloudflare | |
tags: | | |
# Raw version tags | |
type=raw,value=${{ env.VERSION }} | |
# Semver tagging strategy | |
type=semver,pattern={{version}},value=${{ env.VERSION }} | |
type=semver,pattern={{major}}.{{minor}},value=${{ env.VERSION }} | |
type=semver,pattern={{major}},value=${{ env.VERSION }} | |
labels: | | |
org.opencontainers.image.title=Caddy Cloudflare | |
org.opencontainers.image.description=Caddy with Cloudflare DNS module | |
org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }} | |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
org.opencontainers.image.version=${{ env.VERSION }} | |
org.opencontainers.image.licenses=MIT | |
org.opencontainers.image.vendor=${{ github.repository_owner }} | |
- name: Build and push Docker image | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: Dockerfile | |
push: true | |
build-args: | | |
CADDY_VERSION=${{ env.VERSION }} | |
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le,linux/s390x | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.VERSION }} | |
name: "Caddy v${{ env.VERSION }}" | |
body: "New Caddy release detected. See the full release notes [here](https://github.com/caddyserver/caddy/releases/tag/v${{ env.VERSION }})." | |
draft: false | |
prerelease: false |