Skip to content

Update docker.yml

Update docker.yml #26

Workflow file for this run

name: Docker Build
on:
push:
branches:
- master
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Set image tag
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
IMAGE_TAG="${GITHUB_REF#refs/tags/}"
else
IMAGE_TAG="latest"
fi
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
- name: Build Docker image
run: docker build -t api-gateway:${{ env.IMAGE_TAG }} .
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker image
run: |
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
IMAGE_NAME=ghcr.io/$REPO_LOWER
docker tag api-gateway:${{ env.IMAGE_TAG }} $IMAGE_NAME:${{ env.IMAGE_TAG }}
docker push $IMAGE_NAME:${{ env.IMAGE_TAG }}