Skip to content

Publish to GHCR.io #182

Publish to GHCR.io

Publish to GHCR.io #182

Workflow file for this run

---
name: Publish to GHCR.io
on:
schedule:
- cron: '0 3 * * SAT'
push:
branches: [main]
# Publish semver tags as releases.
tags: ['v*.*.*']
pull_request:
branches: [main]
workflow_dispatch:
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
jobs:
build-fuelhook:
runs-on: self-hosted
permissions:
contents: read
packages: write
steps:
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# Set up Docker Buildx
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
config-inline: |
[registry."docker.io"]
mirrors = ["registry-mirror:5000"]
[registry."registry-mirror:5000"]
http = true
driver-opts: |
network=actions-runners
# Gives two env variables
# One with lowercase repo owner's name
# Another with the name of the image
- name: Set image name
run: |
echo "REPO_NAME=${GITHUB_REPOSITORY_OWNER,,}" >> ${GITHUB_ENV} &&
echo "IMAGE_NAME=${GITHUB_JOB#*-}" >> ${GITHUB_ENV}
# Checkout repository
# https://github.com/actions/checkout
- name: Checkout repository
uses: actions/checkout@v4
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: |
github.event_name == 'push' ||
github.event_name == 'schedule'
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
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
tags: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:latest