Skip to content

Docker

Docker #263

Workflow file for this run

name: Docker
on:
push:
branches:
- main
tags:
- v*
pull_request:
schedule:
- cron: '12 4 * * *'
# devel build
- cron: '13 4 * * *'
workflow_dispatch:
inputs:
date:
required: false
type: string
description: YYYYMMDD
push:
required: true
type: boolean
description: Push images
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Prepare configuration
run: |
IMAGE_ID=${{ github.repository_owner }}/latex
if [[ "${{ github.event_name }}" == "schedule" && "${{ github.event.schedule }}" == "12 4 * * *" ]]; then
DATE=$(date '+%Y%m%d')
PUSH="true"
echo "Running scheduled build with date: $DATE"
elif [[ "${{ github.event_name }}" == "schedule" && "${{ github.event.schedule }}" == "13 4 * * *" ]]; then
PUSH="true"
VERSION=devel
MIRROR="https://texlive.info/CTAN/systems/texlive/tlnet"
echo "Running scheduled devel build"
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
if [[ -n "${{ github.event.inputs.date }}" ]]; then
DATE="${{ github.event.inputs.date }}"
else
DATE=$(date '+%Y%m%d')
echo "No date supplied, using today's date"
fi
if [[ "${{ github.event.inputs.push }}" == "true" ]]; then
PUSH="true"
else
PUSH="false"
fi
echo "Running manual build with date: $DATE, push: $PUSH"
elif [[ "${{ github.ref }}" == "refs/tags/v"* ]]; then
PUSH="true"
REF_NAME=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
VERSION=$(echo $REF_NAME | sed -e 's/^v//')
VERSION_YEAR=$(echo $VERSION | sed -e 's/[^0-9].*//')
. MIRRORS
variable=TL_MIRROR_${VERSION_YEAR}
MIRROR=${!variable}
if [[ -z "$MIRROR" ]]; then
echo "Mirror not found for $VERSION_YEAR ($VERSION)"
exit 1
fi
echo "Running build for tag with version: $VERSION"
else
DATE=$(date '+%Y%m%d')
PUSH="false"
echo "Running test build with date: $DATE"
fi
# Will be re-tagged before push
echo "IMAGE_ID=image" | tee -a "$GITHUB_ENV"
echo "VERSION=version" | tee -a "$GITHUB_ENV"
echo "IMAGE_IDS=$IMAGE_ID ghcr.io/$IMAGE_ID" | tee -a "$GITHUB_ENV"
echo "PUSH=$PUSH" | tee -a "$GITHUB_ENV"
if [[ -n "$VERSION" ]]; then
echo "TL_MIRROR=$MIRROR" | tee -a "$GITHUB_ENV"
echo "VERSIONS=$VERSION" | tee -a "$GITHUB_ENV"
else
./.github/workflows/configure_from_date.py "$DATE"
fi
- name: Build minimal
run: |
make minimal
- name: Build basic
run: |
make basic
- name: Run tests
run: |
make test
- name: Build small
if: env.PUSH == 'true'
run: |
make small
- name: Build medium
if: env.PUSH == 'true'
run: |
make medium
- name: Build full
if: env.PUSH == 'true'
run: |
make full
- name: Log in to DockerHub
uses: docker/login-action@v3
if: env.PUSH == 'true'
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
if: env.PUSH == 'true'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push images
if: env.PUSH == 'true'
run: |
for image_id in $IMAGE_IDS; do
for version in $VERSIONS; do
for suffix in "-minimal" "-basic" "-small" "-medium" "-full" "" ; do
image=${image_id}:${version}${suffix}
echo "Tagging and pushing ${image}..."
docker tag ${{ env.IMAGE_ID }}:${{ env.VERSION }}${suffix} ${image}
docker push ${image}
done
done
done