👷 Final Github Action tweaks & updates #44
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 images dev build | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- "**" | |
pull_request: | |
branches: | |
- "main" | |
env: | |
IMAGE_ORG: 'throwtheswitch' | |
IMAGE_BASE_NAME: 'madsciencelab' | |
jobs: | |
# Jobs organized for concurrent Docker image builds | |
# Jobs only build :latest images without pushing to Docker Hub | |
# This is a workaround to the limitation that an `env:` map cannot reference the `env:` map to create additional environment variables | |
image-details: | |
runs-on: ubuntu-latest | |
steps: | |
# A step must be present in order to make use of `outputs:` | |
- run: echo "Setting Docker image details..." | |
outputs: | |
base-name: 'madsciencelab' | |
base-url: 'throwtheswitch/madsciencelab' | |
madsciencelab: | |
runs-on: ubuntu-latest | |
needs: [image-details] | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
env: | |
IMAGE_NAME: ${{ needs.image-details.outputs.base-name }} | |
IMAGE_URL: ${{ needs.image-details.outputs.base-url }} | |
# Image variant name is drawn from final `--dir` entry in file generation command line | |
IMAGE_DIR: build/standard | |
steps: | |
- name: 'Set up Ruby for generation tool' | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.3' | |
bundler-cache: true | |
- name: 'Checkout GitHub Action' | |
uses: actions/checkout@v4 | |
- name: 'Install file generation Ruby dependencies' | |
run: bundle install | |
- name: 'Run file generation' | |
id: file-gen | |
run: bash build.sh --dir ${{ env.IMAGE_DIR }} --version dev | |
- name: 'Set up QEMU' | |
uses: docker/setup-qemu-action@v3 | |
- name: 'Set up Docker Buildx' | |
uses: docker/setup-buildx-action@v3 | |
- name: 'Login to Docker Hub' | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# Docker image: madsciencelab | |
# Note: standard/ directory maps to madsciencelab image (no variants) | |
- name: 'Build Docker image ${{ env.IMAGE_NAME }}' | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
context: . | |
file: ${{ env.IMAGE_DIR }}/docker/Dockerfile | |
build-args: | | |
CONTAINER_VERSION=${{ github.ref_name }} | |
IMAGE_NAME=${{ env.IMAGE_NAME }} | |
tags: ${{ env.IMAGE_URL }}:latest | |
# Connect Docker driver to GitHub Action cache service | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# Zip generated files as a single artifact | |
- name: 'Archive ${{ env.IMAGE_NAME }} generated files as a single artifact' | |
run: zip -j ${{ env.IMAGE_NAME }}.zip ${{ env.IMAGE_DIR }}/docker/Dockerfile ${{ env.IMAGE_DIR }}/assets/shell/welcome | |
# Upload the zip artifact | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.IMAGE_NAME }} | |
path: ${{ env.IMAGE_NAME }}.zip | |
if-no-files-found: error | |
madsciencelab-plugins: | |
runs-on: ubuntu-latest | |
needs: [image-details] | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
env: | |
IMAGE_NAME: ${{ needs.image-details.outputs.base-name }}-plugins | |
IMAGE_URL: ${{ needs.image-details.outputs.base-url }}-plugins | |
# Image variant name is drawn from final `--dir` entry in file generation command line | |
IMAGE_DIR: build/plugins | |
steps: | |
- name: 'Set up Ruby for generation tool' | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.3' | |
bundler-cache: true | |
- name: 'Checkout GitHub Action' | |
uses: actions/checkout@v4 | |
- name: 'Install file generation Ruby dependencies' | |
run: bundle install | |
- name: 'Run file generation' | |
run: bash build.sh --dir build/standard --dir ${{ env.IMAGE_DIR }} --version dev | |
- name: 'Set up QEMU' | |
uses: docker/setup-qemu-action@v3 | |
- name: 'Set up Docker Buildx' | |
uses: docker/setup-buildx-action@v3 | |
- name: 'Login to Docker Hub' | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# Docker image: madsciencelab-plugins | |
- name: 'Build Docker image ${{ env.IMAGE_NAME }}' | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
context: . | |
file: ${{ env.IMAGE_DIR }}/docker/Dockerfile | |
build-args: | | |
CONTAINER_VERSION=${{ github.ref_name }} | |
IMAGE_NAME=${{ env.IMAGE_NAME }} | |
tags: ${{ env.IMAGE_URL }}:latest | |
# Connect Docker driver to GitHub Action cache service | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# Zip generated files as a single artifact | |
- name: 'Archive ${{ env.IMAGE_NAME }} generated files as a single artifact' | |
run: zip -j ${{ env.IMAGE_NAME }}.zip ${{ env.IMAGE_DIR }}/docker/Dockerfile ${{ env.IMAGE_DIR }}/assets/shell/welcome | |
# Upload the zip artifact | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.IMAGE_NAME }} | |
path: ${{ env.IMAGE_NAME }}.zip | |
if-no-files-found: error | |
madsciencelab-arm-none-eabi: | |
runs-on: ubuntu-latest | |
needs: [image-details] | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
env: | |
IMAGE_NAME: ${{ needs.image-details.outputs.base-name }}-arm-none-eabi | |
IMAGE_URL: ${{ needs.image-details.outputs.base-url }}-arm-none-eabi | |
# Image variant name is drawn from final `--dir` entry in file generation command line | |
IMAGE_DIR: build/arm-none-eabi | |
steps: | |
- name: 'Set up Ruby for generation tool' | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.3' | |
bundler-cache: true | |
- name: 'Checkout GitHub Action' | |
uses: actions/checkout@v4 | |
- name: 'Install file generation Ruby dependencies' | |
run: bundle install | |
- name: 'Run file generation' | |
run: bash build.sh --dir ${{ env.IMAGE_DIR }} --version dev | |
- name: 'Set up QEMU' | |
uses: docker/setup-qemu-action@v3 | |
- name: 'Set up Docker Buildx' | |
uses: docker/setup-buildx-action@v3 | |
- name: 'Login to Docker Hub' | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# Docker image: madsciencelab-arm-none-eabi | |
- name: 'Build Docker image ${{ env.IMAGE_NAME }}' | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
context: . | |
file: ${{ env.IMAGE_DIR }}/docker/Dockerfile | |
build-args: | | |
CONTAINER_VERSION=${{ github.ref_name }} | |
IMAGE_NAME=${{ env.IMAGE_NAME }} | |
tags: ${{ env.IMAGE_URL }}:latest | |
# Connect Docker driver to GitHub Action cache service | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# Zip generated files as a single artifact | |
- name: 'Archive ${{ env.IMAGE_NAME }} generated files as a single artifact' | |
run: zip -j ${{ env.IMAGE_NAME }}.zip ${{ env.IMAGE_DIR }}/docker/Dockerfile ${{ env.IMAGE_DIR }}/assets/shell/welcome | |
# Upload the zip artifact | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.IMAGE_NAME }} | |
path: ${{ env.IMAGE_NAME }}.zip | |
if-no-files-found: error | |
madsciencelab-arm-none-eabi-plugins: | |
runs-on: ubuntu-latest | |
needs: [image-details] | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
env: | |
IMAGE_NAME: ${{ needs.image-details.outputs.base-name }}-arm-none-eabi-plugins | |
IMAGE_URL: ${{ needs.image-details.outputs.base-url }}-arm-none-eabi-plugins | |
# Image variant name is drawn from final `--dir` entry in file generation command line | |
IMAGE_DIR: build/arm-none-eabi-plugins | |
steps: | |
- name: 'Set up Ruby for generation tool' | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.3' | |
bundler-cache: true | |
- name: 'Checkout GitHub Action' | |
uses: actions/checkout@v4 | |
- name: 'Install file generation Ruby dependencies' | |
run: bundle install | |
- name: 'Run file generation' | |
run: bash build.sh --dir build/arm-none-eabi --dir build/plugins --dir ${{ env.IMAGE_DIR }} --version dev | |
- name: 'Set up QEMU' | |
uses: docker/setup-qemu-action@v3 | |
- name: 'Set up Docker Buildx' | |
uses: docker/setup-buildx-action@v3 | |
- name: 'Login to Docker Hub' | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# Docker image: madsciencelab-arm-none-eabi-plugins | |
- name: 'Build Docker image ${{ env.IMAGE_NAME }}' | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
context: . | |
file: ${{ env.IMAGE_DIR }}/docker/Dockerfile | |
build-args: | | |
CONTAINER_VERSION=${{ github.ref_name }} | |
IMAGE_NAME=${{ env.IMAGE_NAME }} | |
tags: ${{ env.IMAGE_URL }}:latest | |
# Connect Docker driver to GitHub Action cache service | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# Zip generated files as a single artifact | |
- name: 'Archive ${{ env.IMAGE_NAME }} generated files as a single artifact' | |
run: zip -j ${{ env.IMAGE_NAME }}.zip ${{ env.IMAGE_DIR }}/docker/Dockerfile ${{ env.IMAGE_DIR }}/assets/shell/welcome | |
# Upload the zip artifact | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.IMAGE_NAME }} | |
path: ${{ env.IMAGE_NAME }}.zip | |
if-no-files-found: error | |
# After all Docker image builds, collect results and publish a pre-release | |
artifacts-dev-build: | |
runs-on: ubuntu-latest | |
needs: | |
- madsciencelab | |
- madsciencelab-plugins | |
- madsciencelab-arm-none-eabi | |
- madsciencelab-arm-none-eabi-plugins | |
permissions: | |
contents: write | |
steps: | |
# Get the repo so we have info for generating release details | |
- name: 'Checkout GitHub Action' | |
uses: actions/checkout@v4 | |
# Download all artifacts from the 4 Docker image builds | |
- uses: actions/download-artifact@v4 | |
with: | |
# `pattern:` is a workaround to an artifact upload incompatibility with docker/build-push-action@v6 | |
# Otherwise, apart from this bug requiring `pattern:` the default of all artifacts would occur without any intervention | |
# https://github.com/docker/build-push-action/issues/1167 | |
pattern: "madsciencelab*" | |
path: artifacts | |
# Capture the SHA string | |
- name: 'Git commit short SHA as environment variable' | |
shell: bash | |
run: | | |
echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- uses: ncipollo/release-action@v1 | |
with: | |
prerelease: true | |
allowUpdates: true | |
bodyFile: .github/workflows/release.md | |
commit: ${{ github.sha }} | |
tag: ${{ env.SHA_SHORT }} | |
name: Dev Build ${{ env.SHA_SHORT }} | |
artifacts: "artifacts/*/*.zip" |