Skip to content

Fixes duplicate GitHub Action execution on branch main #2

Fixes duplicate GitHub Action execution on branch main

Fixes duplicate GitHub Action execution on branch main #2

name: Build Docker images
on:
push:
branches:
- 'main'
- '!testing/**'
- '!feature/**'
- '!hotfix/**'
env:
# Template URL
TEMPLATE_SRC: "https://api.github.com/repos/Wandmalfarbe/pandoc-latex-template/releases/latest"
permissions:
contents: write
jobs:
collect-github-api-artifacts:
runs-on: [ubuntu-22.04]
steps:
- name: Find template source
run: |
RESPONSE=$(curl -s $TEMPLATE_SRC)
echo "curl: $RESPONSE"
LATEST_SRC=$(echo "$RESPONSE" \
| grep "/Eisvogel.zip" \
| cut -d : -f 2,3 \
| tr -d \")
if [[ -z "${LATEST_SRC// }" ]]; then
echo "This runner propably reached it's GitHub API rate limit. Exit."
exit 1
fi
echo "Found URL: $LATEST_SRC"
wget "${LATEST_SRC// }"
- name: Upload template artifact
uses: actions/upload-artifact@v3
with:
name: Eisvogel.zip
path: Eisvogel.zip
build-and-push-image:
needs: [collect-github-api-artifacts]
runs-on: [self-hosted]
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Download template
uses: actions/download-artifact@v3
with:
name: Eisvogel.zip
- name: Build Docker image
run: |
docker build -t pandoc-builder .
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: maxkratz/pandoc-builder:latest
platforms: linux/amd64,linux/arm64,linux/arm/v7