Skip to content

Commit

Permalink
Optimize GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
kjarosh committed Feb 1, 2024
1 parent b8a9222 commit 84bd8d4
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 106 deletions.
102 changes: 0 additions & 102 deletions .github/workflows/docker-publish.yml

This file was deleted.

96 changes: 96 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Docker

on:
push:
branches:
- main
tags:
- v*
pull_request:

jobs:
docker:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v3
- name: Prepare configuration
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo VERSION=$VERSION
echo "VERSION=${VERSION}" >> $GITHUB_ENV
IMAGE_ID=${{ github.actor }}/latex
echo IMAGE_ID=$IMAGE_ID
echo "IMAGE_ID=${IMAGE_ID}" >> $GITHUB_ENV
- name: Build minimal
run: |
make minimal
docker tag ${{ env.IMAGE_ID }}:latest-minimal ${{ env.IMAGE_ID }}:${{ env.VERSION }}-minimal
docker tag ${{ env.IMAGE_ID }}:latest-minimal ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-minimal
- name: Build basic
run: |
make basic
docker tag ${{ env.IMAGE_ID }}:latest-basic ${{ env.IMAGE_ID }}:${{ env.VERSION }}-basic
docker tag ${{ env.IMAGE_ID }}:latest-basic ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-basic
- name: Build small
run: |
make small
docker tag ${{ env.IMAGE_ID }}:latest-small ${{ env.IMAGE_ID }}:${{ env.VERSION }}-small
docker tag ${{ env.IMAGE_ID }}:latest-small ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-small
- name: Build medium
run: |
make medium
docker tag ${{ env.IMAGE_ID }}:latest-medium ${{ env.IMAGE_ID }}:${{ env.VERSION }}-medium
docker tag ${{ env.IMAGE_ID }}:latest-medium ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-medium
- name: Build full
run: |
make full
docker tag ${{ env.IMAGE_ID }}:latest-full ${{ env.IMAGE_ID }}:${{ env.VERSION }}-full
docker tag ${{ env.IMAGE_ID }}:latest-full ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}-full
docker tag ${{ env.IMAGE_ID }}:latest-full ${{ env.IMAGE_ID }}:${{ env.VERSION }}
docker tag ${{ env.IMAGE_ID }}:latest-full ghcr.io/${{ env.IMAGE_ID }}:${{ env.VERSION }}
- name: Run tests
run: |
make test
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push images
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 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 }}
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
IMAGE_ID ?= kjarosh/latex
VERSION ?= latest

_default: medium
_default: all

all: minimal basic small medium full

Expand Down Expand Up @@ -41,7 +41,6 @@ full:
--build-arg TL_SCHEME_FULL=y

test:
docker compose -f test.compose.yaml build
docker compose -f test.compose.yaml run sut
docker compose -f test.compose.yaml run --build sut

.PHONY: *
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# LaTeX in Docker

![GitHub license](https://img.shields.io/github/license/kjarosh/latex-docker)
![GitHub build status](https://img.shields.io/github/actions/workflow/status/kjarosh/latex-docker/docker-publish.yml?branch=main)
![GitHub build status](https://img.shields.io/github/actions/workflow/status/kjarosh/latex-docker/docker.yml?branch=main)
[![GitHub release](https://img.shields.io/github/v/release/kjarosh/latex-docker)](https://github.com/kjarosh/latex-docker/releases)
[![DockerHub](https://img.shields.io/badge/docker.io-kjarosh%2Flatex-blue)](https://hub.docker.com/r/kjarosh/latex)
[![GitHub Container Registry](https://img.shields.io/badge/ghcr.io-kjarosh%2Flatex-blue)](https://github.com/users/kjarosh/packages/container/package/latex)
Expand Down

0 comments on commit 84bd8d4

Please sign in to comment.