Skip to content

Fix error handling and syntax for git config commands. Go back to one… #19

Fix error handling and syntax for git config commands. Go back to one…

Fix error handling and syntax for git config commands. Go back to one… #19

name: Build and Push Docker Image
on:
push:
branches:
- main
paths:
- 'build/dockerfile'
- 'build/requirements.txt'
- 'build/docker-compose.yml'
- '.github/workflows/build-docker-image.yml'
jobs:
build-and-push-docker-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Lowercase the image name
run: echo "IMAGE_NAME=${IMAGE_NAME,,}" >> $GITHUB_ENV
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image with Compose
run: docker compose -f build/docker-compose.yml build
- name: Tag Docker images
run: |
docker tag "$IMAGE_NAME:latest" "$IMAGE_NAME:latest"
docker tag "$IMAGE_NAME:latest" "$IMAGE_NAME:git-${GITHUB_SHA::7}"
- name: Push Docker images
run: |
docker push "$IMAGE_NAME:latest"
docker push "$IMAGE_NAME:git-${GITHUB_SHA::7}"