Skip to content

Create docker-image.yml #6

Create docker-image.yml

Create docker-image.yml #6

Workflow file for this run

name: Build and Push Docker
permissions: read-all
on:
push:
branches:
- main
jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
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.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: false
- name: Extract version and increment
id: versioning
run: |
# Get the latest tag from git
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
# Strip the 'v' prefix if it exists
VERSION=${VERSION#v}
# Split the version into its components
IFS='.' read -r -a VERSION_PARTS <<< "$VERSION"
# Increment the patch version
NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$((VERSION_PARTS[2] + 1))"
# Output the new version
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}/imageproxy:${{ steps.versioning.outputs.new_version }}
platforms: linux/amd64,linux/arm64