feat: add the GitHub action to create a Docker image and push to Docker's registry

pull/2386/head
Chaitanya Rahalkar 1 month ago
parent 1233a2efa4
commit 255207f7a6

@ -0,0 +1,57 @@
name: Build and Push Docker Images
on:
schedule:
- cron: '0 0 1 * *' # Run monthly on the 1st
workflow_dispatch: # Allow manual triggers
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=raw,value={{date 'YYYYMMDD'}}
- name: Build and push regular image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push Alpine image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile-alpine
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:alpine-{{date 'YYYYMMDD'}}
labels: ${{ steps.meta.outputs.labels }}
Loading…
Cancel
Save