Docker #47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
pull_request: | |
schedule: | |
- cron: '12 4 * * *' | |
workflow_dispatch: | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Prepare configuration | |
run: | | |
IMAGE_ID=${{ github.repository_owner }}/latex | |
echo IMAGE_ID=$IMAGE_ID | |
echo "IMAGE_ID=${IMAGE_ID}" >> $GITHUB_ENV | |
if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
VERSION=$(date '+%Y%m%d') | |
TL_MIRROR="https://www.texlive.info/tlnet-archive/$(date '+%Y')/$(date '+%m')/$(date '+%d')/tlnet/" | |
echo Using daily version: $VERSION | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
echo Using mirror: TL_MIRROR | |
echo "TL_MIRROR=${TL_MIRROR}" >> $GITHUB_ENV | |
echo "PUSH=true" >> $GITHUB_ENV | |
elif [[ "${{ github.ref }}" == "refs/tags/v"* ]]; then | |
REF_NAME=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
VERSION=$(echo $REF_NAME | sed -e 's/^v//') | |
echo Using version from tag: $VERSION | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
echo "PUSH=true" >> $GITHUB_ENV | |
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
VERSION=latest | |
echo Using version based on main: $VERSION | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
echo "PUSH=true" >> $GITHUB_ENV | |
else | |
VERSION=$(git rev-parse --short HEAD) | |
echo Using version based on commit hash: $VERSION | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
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: | | |
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}-minimal | |
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}-basic | |
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}-small | |
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}-medium | |
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}-full | |
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }} | |
docker tag ${{ env.IMAGE_ID }}:${{ env.VERSION }}-minimal ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-minimal | |
docker tag ${{ env.IMAGE_ID }}:${{ env.VERSION }}-basic ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-basic | |
docker tag ${{ env.IMAGE_ID }}:${{ env.VERSION }}-small ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-small | |
docker tag ${{ env.IMAGE_ID }}:${{ env.VERSION }}-medium ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-medium | |
docker tag ${{ env.IMAGE_ID }}:${{ env.VERSION }}-full ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-full | |
docker tag ${{ env.IMAGE_ID }}:${{ env.VERSION }} ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }} | |
docker push ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-minimal | |
docker push ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-basic | |
docker push ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-small | |
docker push ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-medium | |
docker push ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-full | |
docker push ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }} |