Skip to content

Address gemini code review #58

Address gemini code review

Address gemini code review #58

Workflow file for this run

name: Docker Image CI
on:
push:
tags:
- '*'
branches:
- master
- dev
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: mesudip
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Generate Docker tags
id: tags
if: startsWith(github.ref, 'refs/tags/')
run: |
TAG_NAME="${{ github.ref_name }}"
echo "Processing tag: $TAG_NAME"
# Base tags: explicit tag + latest
TAG_LIST="mesudip/nginx-proxy:${TAG_NAME},mesudip/nginx-proxy:latest"
# Extract major version (e.g. v3.0.1 -> v3, 2.0 -> 2)
if [[ "$TAG_NAME" =~ ^(v?[0-9]+) ]]; then
MAJOR_TAG="${BASH_REMATCH[1]}"
if [ "$MAJOR_TAG" != "$TAG_NAME" ]; then
TAG_LIST="${TAG_LIST},mesudip/nginx-proxy:${MAJOR_TAG}"
fi
fi
echo "Generated tags: $TAG_LIST"
echo "tags_list=$TAG_LIST" >> $GITHUB_OUTPUT
- name: Build and push for tags
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v5
with:
file: Dockerfile
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.tags.outputs.tags_list }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push for main branch
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v5
with:
file: Dockerfile
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: mesudip/nginx-proxy:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max