Skip to content

Publish Docker image #67

Publish Docker image

Publish Docker image #67

# Based on
# <https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages>.
name: Publish Docker image
on:
workflow_dispatch:
schedule:
# Update it once a week, on Sunday
- cron: 02 01 * * 0
env:
REGISTRY: ghcr.io
# Note: the image name must be lowercase.
IMAGE_NAME: tlomodel/actions-runner
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest