Update python Docker tag to v3.13 #17
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: Release | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- 'apps/**' | |
- 'base/**' | |
pull_request: | |
paths: | |
- 'apps/**' | |
- 'base/**' | |
# Detect which folders in project-root (which contain the containers) contain changes | |
jobs: | |
changes: | |
name: Get changes | |
runs-on: ubuntu-20.04 | |
outputs: | |
matrix: "{\"container\": ${{ steps.reduce.outputs.containers }} }" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
list-files: json | |
filters: | | |
changed: | |
- 'apps/**' | |
- 'base/**' | |
- run: echo '${{ toJson(steps.filter.outputs) }}' > changes.json | |
- id: reduce | |
run: | | |
CONTAINERS=$(jq --raw-output '.changed_files | fromjson | .[] |= sub("(?<filepath>(?<first_directory>(?<root1>[/]?)[^/]+/)(?<second_directory>(?<root2>[/]?)[^/]+)(?<extra_paths>.+))"; "\(.second_directory)") | unique' changes.json) | |
echo ::set-output name=containers::${CONTAINERS} | |
build: | |
name: Build | |
runs-on: ubuntu-20.04 | |
needs: | |
- changes | |
strategy: | |
matrix: ${{ fromJson(needs.changes.outputs.matrix) }} | |
fail-fast: false | |
if: "!contains(github.event.head_commit.message, '[ci-skip]')" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | |
# Define if tests and push should be run against which versions/platforms | |
- name: Prepare | |
id: prep | |
run: | | |
BUILD_DATE=$(date --rfc-3339=seconds --utc) | |
echo ::set-output name=build_date::${BUILD_DATE} | |
if test -f "./apps/${{ matrix.container }}/Dockerfile"; then | |
CATEGORY="apps" | |
else | |
CATEGORY="base" | |
fi | |
echo ::set-output name=category::${CATEGORY} | |
VERSION=$(cat ./${CATEGORY}/${{ matrix.container }}/VERSION) | |
echo ::set-output name=version::${VERSION} | |
PLATFORM=$(cat ./${CATEGORY}/${{ matrix.container }}/PLATFORM) | |
echo ::set-output name=platform::${PLATFORM} | |
if [ "${{github.event_name}}" == "pull_request" ]; then | |
echo ::set-output name=push::false | |
echo ::set-output name=cache_from::"type=local,src=/tmp/.buildx-cache" | |
echo ::set-output name=cache_to::"" | |
else | |
echo ::set-output name=push::true | |
echo ::set-output name=cache_from::"type=local,src=/tmp/.buildx-cache" | |
echo ::set-output name=cache_to::"type=local,dest=/tmp/.buildx-cache,mode=max" | |
fi | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: amd64,arm64 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
if: github.event_name != 'pull_request' | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Install and configure Buildx | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
version: latest | |
driver-opts: image=moby/buildkit:latest | |
- name: Cache Docker layers | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ secrets.DOCKER_REGISTRY }}/${{ github.repository_owner }}/${{ matrix.container }} | |
restore-keys: | | |
${{ secrets.DOCKER_REGISTRY }}/${{ github.repository_owner }}/${{ matrix.container }} | |
# Push if not a PR, otherwise just test the build process for all requested platforms | |
- name: Build and Push | |
uses: docker/build-push-action@v6 | |
with: | |
build-args: VERSION=${{ steps.prep.outputs.version }} | |
labels: | | |
org.opencontainers.image.created=${{ steps.prep.outputs.build_date }} | |
context: . | |
platforms: ${{ steps.prep.outputs.platform }} | |
file: ./${{ steps.prep.outputs.category }}/${{ matrix.container }}/Dockerfile | |
push: ${{ steps.prep.outputs.push }} | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/${{ matrix.container }}:latest | |
ghcr.io/${{ github.repository_owner }}/${{ matrix.container }}:v${{ steps.prep.outputs.version }} | |
cache-from: ${{ steps.prep.outputs.cache_from }} | |
cache-to: ${{ steps.prep.outputs.cache_to }} |