Image Builder #689
This file contains hidden or 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: Image Builder | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| pandoc_version: | |
| description: >- | |
| Version; must be either `edge` or the number of a pandoc release | |
| default: edge | |
| type: string | |
| base_system: | |
| description: Docker base system | |
| default: alpine | |
| type: choice | |
| options: | |
| - alpine | |
| - debian | |
| - static | |
| - ubuntu | |
| no_cache: | |
| type: boolean | |
| default: false | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| # A depth of ten should be enough to get the "github.event.before" | |
| # commit. However, pushing more commits might cause issues. | |
| fetch-depth: 10 | |
| - id: set-matrix | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| echo "matrix={\"include\":[{\"stack\":\"${{ inputs.base_system }}\",\"version\":\"${{ inputs.pandoc_version }}\"}]}" >> $GITHUB_OUTPUT | |
| else | |
| CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }}) | |
| MATRIX="{\"include\":[" | |
| FIRST=true | |
| for STACK in alpine ubuntu static; do | |
| if echo "$CHANGED_FILES" | grep -q "^$STACK/"; then | |
| FREEZE_FILE=$(echo "$CHANGED_FILES" | grep "^$STACK/.*\.project\.freeze$" | head -1) | |
| if [ -n "$FREEZE_FILE" ]; then | |
| VERSION=$(basename "$FREEZE_FILE" | sed -E 's/pandoc-(.*)\.project\.freeze/\1/') | |
| if [ "$FIRST" = true ]; then | |
| FIRST=false | |
| else | |
| MATRIX="${MATRIX}," | |
| fi | |
| MATRIX="${MATRIX}{\"stack\":\"${STACK:-alpine}\",\"version\":\"${VERSION:-main}\"}" | |
| fi | |
| fi | |
| done | |
| MATRIX="${MATRIX}]}" | |
| echo "matrix=$MATRIX" >> $GITHUB_OUTPUT | |
| fi | |
| core: | |
| name: minimal and core (${{ matrix.stack }}) | |
| needs: prepare | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }} | |
| fail-fast: false | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| version: "lab:latest" | |
| driver: cloud | |
| endpoint: "pandoc/multiarch" | |
| - name: minimal | |
| timeout-minutes: 25 | |
| uses: ./.github/actions/build | |
| with: | |
| image_type: minimal | |
| base_system: ${{ matrix.stack }} | |
| pandoc_version: ${{ matrix.version }} | |
| target: minimal | |
| no_cache: ${{ inputs.no_cache }} | |
| - name: core | |
| uses: ./.github/actions/build | |
| if: ${{ matrix.stack != 'static' }} | |
| with: | |
| image_type: core | |
| base_system: ${{ matrix.stack }} | |
| pandoc_version: ${{ matrix.version }} | |
| target: core | |
| # We always want to make use of caching for this step | |
| no_cache: false | |
| typst: | |
| name: Typst (${{ matrix.stack }}) | |
| if: ${{ !contains(needs.prepare.outputs.matrix, '"stack":"static"') }} | |
| needs: [prepare, core] | |
| strategy: | |
| matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }} | |
| fail-fast: false | |
| uses: ./.github/workflows/addon.yaml | |
| secrets: inherit | |
| with: | |
| addon: typst | |
| base_system: ${{ matrix.stack }} | |
| pandoc_version: ${{ matrix.version }} | |
| no_cache: ${{ inputs.no_cache }} | |
| latex: | |
| name: LaTeX (${{ matrix.stack }}) | |
| if: ${{ !contains(needs.prepare.outputs.matrix, '"stack":"static"') }} | |
| needs: [prepare, core] | |
| strategy: | |
| matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }} | |
| fail-fast: false | |
| uses: ./.github/workflows/addon.yaml | |
| secrets: inherit | |
| with: | |
| addon: latex | |
| base_system: ${{ matrix.stack }} | |
| pandoc_version: ${{ matrix.version }} | |
| no_cache: ${{ inputs.no_cache }} | |
| extra: | |
| name: Extra (${{ matrix.stack }}) | |
| if: ${{ !contains(needs.prepare.outputs.matrix, '"stack":"static"') }} | |
| needs: [prepare, latex] | |
| strategy: | |
| matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }} | |
| fail-fast: false | |
| uses: ./.github/workflows/addon.yaml | |
| secrets: inherit | |
| with: | |
| addon: extra | |
| base_system: ${{ matrix.stack }} | |
| pandoc_version: ${{ matrix.version }} | |
| no_cache: ${{ inputs.no_cache }} |