Skip to content

Merge pull request #8 from neoKushan/docker-ci #2

Merge pull request #8 from neoKushan/docker-ci

Merge pull request #8 from neoKushan/docker-ci #2

Workflow file for this run

name: Build and Push Docker Image
on:
push:
branches:
- main # Trigger on pushes to the main branch
jobs:
build_and_push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
# This step is a workaround for an issue whereby github artifacts expects repositories to have only lower case names
# See https://github.com/docker/build-push-action/issues/37
- name: PrepareReg Names
run: |
echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
echo IMAGE_TAG=$(echo ${{ github.ref }} | tr '[:upper:]' '[:lower:]' | awk '{split($0,a,"/"); print a[3]}') >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push with commit SHA tag
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ghcr.io/${{ env.IMAGE_REPOSITORY }}:latest, ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ github.sha }}