4.0.4 #127
Workflow file for this run
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 ] | |
# Publish semver tags as releases. | |
tags: [ 'v*.*.*' ] | |
pull_request: | |
branches: [ main ] | |
env: | |
# Use docker.io for Docker Hub if empty | |
REGISTRY: ghcr.io | |
# github.repository as <account>/<repo> | |
IMAGE_NAME: ${{ github.repository }} | |
# tests | |
TEST_TAG: ${{ github.repository }}:test | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# Login against a Docker registry except on PR | |
# https://github.com/docker/login-action | |
- name: Log into registry ${{ env.REGISTRY }} | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Build and export Docker image for tests | |
# https://github.com/docker/build-push-action | |
- name: Build and export to Docker | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
load: true | |
tags: ${{ env.TEST_TAG }} | |
# Test Docker image with PDF generation | |
- name: Test | |
run: | | |
docker run --rm \ | |
--cap-add=SYS_ADMIN \ | |
--user "$(id -u):$(id -g)" \ | |
-v "$(pwd)/docs:/home/node/docs:ro" \ | |
-v "$(pwd)/pdf:/home/node/pdf:rw" \ | |
-v "$(pwd)/resources/covers/cover.pdf:/home/node/resources/cover.pdf:ro" \ | |
-e "PDF_OUTPUT_NAME=TEST-DOCUMENTATION.pdf" \ | |
${{ env.TEST_TAG }} | |
sudo apt-get update -y || true | |
sudo apt-get install -y poppler-utils | |
NB_PAGES=$(pdfinfo pdf/TEST-DOCUMENTATION.pdf | awk '/^Pages:/ {print $2}') | |
if [ "$NB_PAGES" != "13" ]; then | |
echo "PDF has $NB_PAGES pages instead of 13" | |
exit 1 | |
fi | |
# Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
# Build and push Docker image with Buildx (don't push on PR) | |
# https://github.com/docker/build-push-action | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=registry,ref=${{ steps.meta.outputs.tags }} | |
cache-to: type=inline |