Skip to content

Build and push dockerdl-base image #167

Build and push dockerdl-base image

Build and push dockerdl-base image #167

name: Build and push dockerdl-base image
on:
schedule:
# Runs at 00:10 am every Sunday
- cron: "10 0 * * 0"
push:
branches: ["main"]
paths:
- "base.Dockerfile"
- ".github/workflows/docker-publish-base.yml"
pull_request:
branches: ["main"]
paths:
- "base.Dockerfile"
- ".github/workflows/docker-publish-base.yml"
workflow_dispatch:
concurrency:
group: dockerdl-base-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
matifali/dockerdl-base
tags: |
type=raw,value=latest
labels: |
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
org.opencontainers.image.authors=${{ github.event.repository.owner.login }}
- name: Login to DockerHub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
file: base.Dockerfile
push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max