Skip to content

Print output at the end of the step #45

Print output at the end of the step

Print output at the end of the step #45

name: DockerPublish
on:
workflow_dispatch:
push:
env:
# Only push images on forks or the main branch
PUSH_IMAGE: ${{ (github.ref_name == 'master') || (github.repository_owner != 'moos-ivp') }}
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
commit_time: ${{ steps.prepare.outputs.COMMIT_TIMESTAMP }}
registry_image: ${{ steps.prepare.outputs.REGISTRY_IMAGE }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare various metadata
id: prepare
run: |
# Get the commit timestamp
export "COMMIT_TIMESTAMP=$(git log -1 --pretty=%ct)"
echo "COMMIT_TIMESTAMP=$COMMIT_TIMESTAMP" >> $GITHUB_OUTPUT
# Lowercase the repository name
UNSANITIZED_REGISTRY_IMAGE=ghcr.io/${{ github.repository }}
echo "REGISTRY_IMAGE=${UNSANITIZED_REGISTRY_IMAGE,,}" >> $GITHUB_OUTPUT
# Print it for our audience
cat $GITHUB_OUTPUT
build-minrobot:
runs-on: ubuntu-latest
needs:
- prepare
env:
SOURCE_DATE_EPOCH: ${{ needs.prepare.outputs.commit_time }}
REGISTRY_IMAGE: ${{ needs.prepare.outputs.registry_image }}
outputs:
# So we can `FROM` this image in the next build
digest: ${{ steps.build.outputs.digest }}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
# branch event
type=ref,enable=true,prefix=,event=branch
# tag event
type=ref,enable=true,prefix=,event=tag
# pull request event
type=ref,enable=true,prefix=pr-,suffix=,event=pr
# commit sha
type=sha,prefix=,suffix=,format=short
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
annotations: ${{ steps.meta.outputs.annotations }}
build-args: |
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
file: docker/moos-ivp/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
push: ${{ env.PUSH_IMAGE }}
build-gui:
runs-on: ubuntu-latest
needs:
- prepare
- build-minrobot
env:
FLAVOR: "-gui"
SOURCE_DATE_EPOCH: ${{ needs.prepare.outputs.commit_time }}
REGISTRY_IMAGE: ${{ needs.prepare.outputs.registry_image }}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
# branch event
type=ref,enable=true,suffix=${{ env.FLAVOR }},event=branch
# tag event
type=ref,enable=true,suffix=${{ env.FLAVOR }},event=tag
# pull request event
type=ref,enable=true,prefix=pr-,suffix=${{ env.FLAVOR }},event=pr
# commit sha
type=sha,prefix=,suffix=${{ env.FLAVOR }},format=short
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
annotations: ${{ steps.meta.outputs.annotations }}
build-args: |
FROM=${{ env.REGISTRY_IMAGE }}@${{ needs.build-minrobot.outputs.digest }}
SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
file: docker/moos-ivp-gui/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
push: ${{ env.PUSH_IMAGE }}