39 lines
1.1 KiB
YAML
39 lines
1.1 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches: [ main ]
|
|
|
|
env:
|
|
DOCKERHUB_REPO: caddy-test
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
-
|
|
name: Checkout code
|
|
uses: actions/checkout@v4
|
|
-
|
|
name: Parse Caddy version
|
|
id: version
|
|
run: echo "VERSION=$(grep -Eo 'caddy:[0-9]+\.[0-9]+\.[0-9]+$' Dockerfile | cut -d ':' -f2)" >> $GITHUB_ENV
|
|
-
|
|
name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
-
|
|
name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
-
|
|
name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64
|
|
push: ${{ github.event_name != 'workflow_dispatch' }}
|
|
tags: ${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO }}:latest,${{ vars.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO }}:${{ env.VERSION }}
|