Skip to content

ci: add docker image build workflow #5

ci: add docker image build workflow

ci: add docker image build workflow #5

Workflow file for this run

name: Build Docker Image
on: [push, pull_request, workflow_dispatch]
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.actor }}/data-pipeline
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Sanitize branch name for Docker tag
id: tag
run: echo "name=$(echo ${{ github.ref_name }} | sed 's/\//-/g')" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ env.REGISTRY }}/${{ github.actor }}/data-pipeline:${{ steps.tag.outputs.name }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image summary
run: |
echo "### Docker Image Built 🐳" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Image:** ${{ env.REGISTRY }}/${{ github.actor }}/data-pipeline:${{ steps.tag.outputs.name }}" >> $GITHUB_STEP_SUMMARY