1
0
mirror of https://github.com/phusion/baseimage-docker.git synced 2026-03-26 20:38:58 +00:00
Files
baseimage-docker/.github/workflows/main.yml
copilot-swe-agent[bot] 00987409ee Create GH releases on tag push, update deprecated workflow components
- main.yml: Trigger on tag pushes (noble-*, jammy-*) instead of manual
  release published events
- main.yml: Add step to create GitHub release after image build+push
- main.yml: Add contents:write + packages:write permissions
- main.yml: Update docker/build-push-action from v5 to v6
- scheduled-build.yml: Update docker/build-push-action from v5 to v6
- stale.yml: Remove deprecated repo-token parameter

Co-authored-by: samip5 <1703002+samip5@users.noreply.github.com>
2026-02-27 12:51:54 +00:00

103 lines
3.6 KiB
YAML

name: Release
on:
workflow_dispatch:
push:
tags:
- 'noble-*'
- 'jammy-*'
permissions:
contents: write
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=phusion/baseimage
GIT_BRANCH=${GITHUB_REF##*/}
# Set the platforms to build for here and thus reduce duplicating it.
PLATFORMS=amd64,arm,arm64
TAGS="${DOCKER_IMAGE}:${GIT_BRANCH}, ghcr.io/${{ github.repository_owner }}/baseimage:${GIT_BRANCH}"
# Determine BASE_IMAGE from release tag prefix (e.g. noble-1.0.2 -> ubuntu:24.04)
if [[ "${GIT_BRANCH}" == noble-* ]]; then
BASE_IMAGE="ubuntu:24.04"
elif [[ "${GIT_BRANCH}" == jammy-* ]]; then
BASE_IMAGE="ubuntu:22.04"
else
# Default to noble (latest LTS) for unrecognised tag prefixes
echo "::warning::Unrecognized release tag prefix '${GIT_BRANCH}'. Expected it to start with 'noble-' or 'jammy-'. Defaulting BASE_IMAGE to ubuntu:24.04 (Noble)."
BASE_IMAGE="ubuntu:24.04"
fi
# Set output parameters.
if [ "${{github.event_name}}" == "pull_request" ]; then
echo "push=false" >> $GITHUB_OUTPUT
else
echo "push=true" >> $GITHUB_OUTPUT
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "branch=${GIT_BRANCH}" >> $GITHUB_OUTPUT
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
fi
echo "platforms=${PLATFORMS}" >> $GITHUB_OUTPUT
echo "base_image=${BASE_IMAGE}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ steps.prep.outputs.platforms }}
- name: Login to GHCR (Github Container Registry)
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
install: true
version: latest
driver-opts: image=moby/buildkit:latest
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
context: image
platforms: ${{ steps.prep.outputs.platforms }}
push: ${{ steps.prep.outputs.push }}
tags: ${{ steps.prep.outputs.tags }}
build-args: BASE_IMAGE=${{ steps.prep.outputs.base_image }}
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
run: |
gh release create "${{ github.ref_name }}" \
--repo "${{ github.repository }}" \
--title "${{ github.ref_name }}" \
--generate-notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}