Docker Image #445
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 Image | |
on: # yamllint disable-line rule:truthy | |
push: | |
branches: | |
- master | |
- testing | |
paths-ignore: | |
- '.github/**' | |
- '.gitignore' | |
- 'docker-compose.yml' | |
schedule: | |
- cron: '30 18 * * 5' | |
workflow_dispatch: | |
env: | |
IMAGE_NAME: thepoint | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- run: python -m pip install tomlkit gitpython semantic_version | |
- name: Set version | |
id: version | |
env: | |
PYTHONPATH: . | |
run: | | |
import os | |
import pathlib | |
from version import update_version | |
pathlib.Path(os.environ["GITHUB_OUTPUT"]).write_text(f"version={update_version()}") | |
shell: python | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log into registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker image tags | |
id: set_tags | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
BRANCH="$(git branch --show-current)" | |
if [ "$BRANCH" = "master" ]; then | |
echo "tags=$IMAGE_ID:latest,$IMAGE_ID:${{ steps.version.outputs.version }}" >>$GITHUB_OUTPUT | |
elif [ -z "$BRANCH" ]; then | |
echo "tags=$IMAGE_ID:$(git describe --tags)" >>$GITHUB_OUTPUT | |
else | |
echo "tags=$IMAGE_ID:$BRANCH" >>$GITHUB_OUTPUT | |
fi | |
echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >>$GITHUB_OUTPUT | |
if [ "$BRANCH" = "master" -o -z "$BRANCH" ]; then | |
echo "upperroom_version=latest" >>$GITHUB_OUTPUT | |
else | |
echo "upperroom_version=$BRANCH" >>$GITHUB_OUTPUT | |
fi | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
build-args: | | |
"version=${{ steps.version.outputs.version }}" | |
"build_date=${{ steps.set_tags.outputs.build_date }}" | |
"upperroom_version=${{ steps.set_tags.outputs.upperroom_version }}" | |
push: true | |
tags: ${{ steps.set_tags.outputs.tags }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |