Skip to content

ci: add workflow to push docker file to ghcr.io #1

ci: add workflow to push docker file to ghcr.io

ci: add workflow to push docker file to ghcr.io #1

name: Build and push docker image
on:
push:
branches:
- develop
jobs:
build_and_deploy:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
actions: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set commit sha
run: |
COMMIT_SHA=$(git rev-parse --short $GITHUB_SHA)
echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: ghcr.io/${{ github.repository }}:latest, ghcr.io/${{ github.repository }}:${{ env.COMMIT_SHA }}