Skip to content

FM lecture 2025 Matthew Daggitt #242

FM lecture 2025 Matthew Daggitt

FM lecture 2025 Matthew Daggitt #242

Workflow file for this run

name: build docker image
on:
repository_dispatch:
push:
branches:
- master
- 'wip/**'
paths-ignore:
- '.gitignore'
- '.dockerignore'
- 'CHANGELOG.md'
- 'README.md'
- 'LICENSE'
env:
REGISTRY: ghcr.io
jobs:
docker_build:
name: docker build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Check out code
- uses: dorny/paths-filter@v2
id: docker_img_changes
with:
filters: |
src:
- 'Dockerfile'
- 'build.py'
- name: Log in to github Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# not sure this is actually needed
# but note that to use cache later, we always must use "docker buildx build" -
# not "docker build"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# docker-container is actually the default, so
# shouldn't need this. But we _do_ need to build
# using `docker buildx build`.
with:
driver: docker-container
- name: set docker image info from Makefile
#if: steps.docker_img_changes.outputs.src == 'true'
id: info
shell: bash
run: |
set -x
IMAGE_NAME=$(make print-image-name)
IMAGE_VERSION=$(make print-image-version)
echo "::set-output name=IMAGE_NAME::${IMAGE_NAME}"
echo "::set-output name=IMAGE_VERSION::${IMAGE_VERSION}"
- name: check info ok
#if: steps.docker_img_changes.outputs.src == 'true'
run: |
IMAGE_NAME="${{ steps.info.outputs.IMAGE_NAME }}"
printf 'IMAGE_NAME is: <<%s>>\n' "${IMAGE_NAME}"
if [ -z ${IMAGE_NAME} ]; then
false
fi
IMAGE_VERSION="${{ steps.info.outputs.IMAGE_VERSION }}"
printf 'IMAGE_VERSION is: <<%s>>\n' "${IMAGE_VERSION}"
if [ -z ${IMAGE_VERSION} ]; then
false
fi
- name: Extract metadata (tags, labels) for Docker
#if: steps.docker_img_changes.outputs.src == 'true'
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: debug - dump metadata
#if: steps.docker_img_changes.outputs.src == 'true'
shell: bash
run: |
printf 'tags are: <<%s>>\n' "${{ steps.meta.outputs.tags }}"
printf 'tags labels are: <<%s>>\n' "${{ steps.meta.outputs.labels }}"
printf 'repos is: <<%s>>\n' "${{ github.repository }}"
- name: Build Docker image
#if: steps.docker_img_changes.outputs.src == 'true'
shell: bash
run: |
set -x
export IMAGE_NAME="${{ steps.info.outputs.IMAGE_NAME }}"
export GH_IMAGE_ID="${{ env.REGISTRY }}/${{ github.repository }}/${{ steps.info.outputs.IMAGE_NAME }}"
export IMAGE_VERSION="${{ steps.info.outputs.IMAGE_VERSION }}"
export REPO_OWNER="${{ github.repository_owner }}"
echo "${{ steps.meta.outputs.labels }}" > oc_labels
# "
python3 ./build.py
- name: push to github registry
#if: github.event_name != 'pull_request' && steps.docker_img_changes.outputs.src == 'true'
shell: bash
run: |
set -x
set -euo pipefail
GH_IMAGE_ID=${{ env.REGISTRY }}/${{ github.repository }}/${{ steps.info.outputs.IMAGE_NAME }}
IMAGE_VERSION=${{ steps.info.outputs.IMAGE_VERSION }}
docker push ${GH_IMAGE_ID}:${IMAGE_VERSION}
docker tag ${GH_IMAGE_ID}:${IMAGE_VERSION} ${GH_IMAGE_ID}:latest
docker push ${GH_IMAGE_ID}:latest
publish:
runs-on: ubuntu-latest
needs: docker_build
steps:
- uses: actions/checkout@v2
- name: Log in to github Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build site
shell: bash
run: |
set -x
make IMG=${{ env.REGISTRY }}/${{ github.repository }}/cits5501-website:latest \
build
ls -alt
sudo ls -alt `sudo find out -type f | sort`
- name: deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/master' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out/_site
force_orphan: true