As the branch field has a default value "master", this default not only applies when the dialog box for starting the manual workflow is presented. But even if the prefilled branch field is cleared, the default value also gets substituted when submitting. In this case, when the commit and branch fields are mutually exclusive, we can't easily have a default. Instead change the uses of the fields, ignoring the branch field if the commit field is filled. If the dawidd6/action-download-artifact action would support specifying either a commit or a branch in the same field, like actions/checkout does, we wouldn't need this distinction at all; this request is tracked upstream at https://github.com/dawidd6/action-download-artifact/issues/242.
145 lines
4.5 KiB
YAML
145 lines
4.5 KiB
YAML
name: Build docker images
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
commit:
|
|
description: 'Commit to extract from'
|
|
type: string
|
|
branch:
|
|
description: 'Branch to extract from'
|
|
type: string
|
|
default: 'master'
|
|
login:
|
|
description: 'Log in to Docker Hub'
|
|
type: boolean
|
|
default: true
|
|
push:
|
|
description: 'Push the built images'
|
|
type: boolean
|
|
default: false
|
|
|
|
jobs:
|
|
prepare:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
TAG: ${{steps.get-parameters.outputs.TAG}}
|
|
steps:
|
|
- name: Download build parameters
|
|
uses: dawidd6/action-download-artifact@v6
|
|
with:
|
|
workflow: build.yml
|
|
workflow_conclusion: success
|
|
commit: ${{inputs.commit}}
|
|
branch: ${{inputs.commit == '' && inputs.branch || ''}}
|
|
event: push
|
|
name: parameters
|
|
- name: Get build parameters
|
|
id: get-parameters
|
|
run: |
|
|
cat parameters.txt >> $GITHUB_OUTPUT
|
|
cat $GITHUB_OUTPUT
|
|
|
|
docker-build-dev:
|
|
needs: [prepare]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ (inputs.commit != '' && inputs.commit) || inputs.branch }}
|
|
- name: Log in to Docker Hub
|
|
if: ${{inputs.login}}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{vars.DOCKER_USERNAME}}
|
|
password: ${{secrets.DOCKER_PASSWORD}}
|
|
- name: Build Docker images
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: ${{inputs.push}}
|
|
file: ./Dockerfile.dev
|
|
tags: |
|
|
mstorsjo/llvm-mingw:dev
|
|
mstorsjo/llvm-mingw:dev-${{needs.prepare.outputs.TAG}}
|
|
- name: Inspect Docker images
|
|
run: |
|
|
docker images
|
|
|
|
docker-build:
|
|
needs: [prepare]
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- { file: Dockerfile, key: amd64 }
|
|
- { file: Dockerfile.toolchain, platforms: linux/arm64, key: arm64 }
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ (inputs.commit != '' && inputs.commit) || inputs.branch }}
|
|
- name: Download toolchain
|
|
if: ${{matrix.file == 'Dockerfile.toolchain'}}
|
|
uses: dawidd6/action-download-artifact@v6
|
|
with:
|
|
workflow: build.yml
|
|
workflow_conclusion: success
|
|
commit: ${{inputs.commit}}
|
|
branch: ${{inputs.commit == '' && inputs.branch || ''}}
|
|
event: push
|
|
name: linux-ucrt-.*
|
|
name_is_regexp: true
|
|
path: toolchain
|
|
- name: Set up QEMU
|
|
if: ${{matrix.file == 'Dockerfile.toolchain'}}
|
|
uses: docker/setup-qemu-action@v3
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
- name: Log in to Docker Hub
|
|
if: ${{inputs.login}}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{vars.DOCKER_USERNAME}}
|
|
password: ${{secrets.DOCKER_PASSWORD}}
|
|
- name: Build Docker images
|
|
uses: docker/build-push-action@v5
|
|
id: build
|
|
with:
|
|
context: .
|
|
platforms: ${{matrix.platforms}}
|
|
push: ${{inputs.push}}
|
|
file: ./${{matrix.file}}
|
|
outputs: |
|
|
type=image,name=mstorsjo/llvm-mingw,push-by-digest=true,name-canonical=true
|
|
- name: Write outputs for later steps
|
|
uses: cloudposse/github-action-matrix-outputs-write@main
|
|
id: out
|
|
with:
|
|
matrix-step-name: ${{github.job}}
|
|
matrix-key: ${{matrix.key}}
|
|
outputs: |-
|
|
digest: ${{steps.build.outputs.digest}}
|
|
|
|
docker-create:
|
|
needs: [docker-build, prepare]
|
|
runs-on: ubuntu-latest
|
|
if: ${{inputs.push}}
|
|
steps:
|
|
- uses: cloudposse/github-action-matrix-outputs-read@main
|
|
id: read
|
|
with:
|
|
matrix-step-name: docker-build
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{vars.DOCKER_USERNAME}}
|
|
password: ${{secrets.DOCKER_PASSWORD}}
|
|
- name: Create final image
|
|
run: |
|
|
set -x
|
|
for tag in latest ${{needs.prepare.outputs.TAG}}; do
|
|
docker buildx imagetools create -t mstorsjo/llvm-mingw:$tag mstorsjo/llvm-mingw@${{fromJson(steps.read.outputs.result).digest.amd64}} mstorsjo/llvm-mingw@${{fromJson(steps.read.outputs.result).digest.arm64}}
|
|
done
|