Skip to content

Commit

Permalink
Add daily builds
Browse files Browse the repository at this point in the history
  • Loading branch information
kjarosh committed Mar 25, 2024
1 parent add37db commit 5294c0b
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
tags:
- v*
pull_request:
schedule:
- cron: '42 22 * * *'

jobs:
docker:
Expand All @@ -15,24 +17,34 @@ jobs:
- uses: actions/checkout@v3
- name: Prepare configuration
run: |
REF_NAME=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
VERSION=
if [[ "${{ github.event_name }}" == "schedule" ]]; then
VERSION=$(date '+%Y%m%d')
TL_MIRROR="https://www.texlive.info/tlnet-archive/$(date '+%Y')/$(date '+%m')/$(date '+%d')/tlnet/"
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $REF_NAME | sed -e 's/^v//')
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//')
# Use Docker `latest` tag convention
[[ "${{ github.ref }}" == "refs/heads/main" ]] && VERSION=latest
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
# Use commit hash otherwise
[[ -z "$VERSION" ]] && VERSION=${{ github.sha }}
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 VERSION=$VERSION
echo "VERSION=${VERSION}" >> $GITHUB_ENV
IMAGE_ID=${{ github.repository_owner }}/latex
echo IMAGE_ID=$IMAGE_ID
echo "IMAGE_ID=${IMAGE_ID}" >> $GITHUB_ENV
echo Using version based on commit hash: $VERSION
echo "VERSION=${VERSION}" >> $GITHUB_ENV
fi
- name: Build minimal
run: |
Expand All @@ -43,14 +55,17 @@ jobs:
make basic
- 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
Expand All @@ -60,20 +75,20 @@ jobs:
- name: Log in to DockerHub
uses: docker/login-action@v2
if: github.ref == 'refs/heads/main'
if: env.PUSH == 'true'
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
if: github.ref == 'refs/heads/main'
if: env.PUSH == 'true'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push images
if: github.ref == 'refs/heads/main'
if: env.PUSH == 'true'
run: |
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}-minimal
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}-basic
Expand Down

0 comments on commit 5294c0b

Please sign in to comment.