Skip to content
This repository was archived by the owner on Aug 26, 2026. It is now read-only.

Add a cleanup workflow #5

Add a cleanup workflow

Add a cleanup workflow #5

name: Build and Publish Docker Image
on:
push:
branches:
- main
tags:
- 'v*'
paths:
- 'Dockerfile'
- 'docker-entrypoint.sh'
- '.github/workflows/docker-publish.yml'
pull_request:
branches:
- main
paths:
- 'Dockerfile'
- 'docker-entrypoint.sh'
workflow_dispatch:
inputs:
mybb_version:
description: 'MyBB version to build (e.g., 1839)'
required: false
default: '1839'
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@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
MYBB_VERSION=${{ github.event.inputs.mybb_version || '1839' }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Build multiple MyBB versions on release
build-versions:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
mybb_version: ['1836', '1837', '1838', '1839']
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push MyBB ${{ matrix.mybb_version }}
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.mybb_version }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:mybb-${{ matrix.mybb_version }}
build-args: |
MYBB_VERSION=${{ matrix.mybb_version }}
cache-from: type=gha
cache-to: type=gha,mode=max