Skip to content

Create docker-publish.yml #7

Create docker-publish.yml

Create docker-publish.yml #7

Workflow file for this run

name: Build and Push Docker Image to GHCR
on:
push:
branches: [ main, prod2 ]
pull_request:
branches: [ main, prod2 ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Log in to GitHub Container Registry
run: docker login ghcr.io -u ${{ secrets.USERNAME }} -p ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create Buildx builder
run: docker buildx create --use
- name: Inspect Buildx builder
run: docker buildx inspect --bootstrap
- name: Get short Git SHA
id: vars
run: |
REF_PART=${GITHUB_REF#*/}
INDEX=${REF_PART:0:8}
echo "INDEX=$INDEX" >> $GITHUB_ENV
- name: Build and Push Multi-Platform Docker Image
run: |
IMAGE_TAG=ghcr.io/${{ github.repository_owner }}/anokha-2024:${{ github.ref_name }}-${{ env.GIT_SHA }}
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag $IMAGE_TAG \
--tag ghcr.io/${{ github.repository_owner }}/anokha-2024:latest \
--push .
- name: Log out from Docker
run: docker logout ghcr.io