Merge pull request #7 from omarfawzi/codex/add-ci-to-publish-github-p… #20
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: Docker Build | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
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: | | |
IMAGE_NAME=ghcr.io/${{ github.repository }}/api-gateway | |
docker tag api-gateway:${{ env.IMAGE_TAG }} $IMAGE_NAME:${{ env.IMAGE_TAG }} | |
docker push $IMAGE_NAME:${{ env.IMAGE_TAG }} |