Skip to content

Commit

Permalink
ci: docker image build script
Browse files Browse the repository at this point in the history
  • Loading branch information
atrifat committed Jun 7, 2024
1 parent e9b852d commit c1731a7
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build Docker Image

on:
push:
branches: ["main", "dev"]
tags: ["v*"]
workflow_dispatch:

env:
REGISTRY: ghcr.io

jobs:
build-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract Docker metadata
if: ${{ !env.ACT }}
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}

- name: Log into Container Registry
if: github.event_name != 'pull_request' && ${{ !env.ACT }}
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
if: github.event_name != 'pull_request' && ${{ !env.ACT }}
with:
context: .
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit c1731a7

Please sign in to comment.