moved teddyCloud starting guide #79
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 Publish Matrix | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
- develop | |
tags: | |
- tc_nightly* | |
- tc_v*.*.* | |
pull_request: | |
branches: [ "master", "develop" ] | |
# permissions are needed if pushing to ghcr.io | |
permissions: | |
packages: write | |
env: | |
REGISTRY_IMAGE: ghcr.io/toniebox-reverse-engineering/teddycloud | |
jobs: | |
build-container_matrix: | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GHCR | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker meta matrix | |
id: matrix_meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
tags: | | |
type=schedule | |
type=schedule,pattern=nightly | |
type=schedule,pattern={{date 'YYYYMMDD'}} | |
type=schedule,pattern={{date 'YYYYMMDD-hhmmss' tz='Germany/Berlin'}} | |
type=ref,event=branch | |
type=ref,event=pr | |
type=sha | |
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/tc_v') }} | |
type=raw,value=nightly,enable=${{ startsWith(github.ref, 'refs/tags/tc_nightly') }} | |
type=raw,value=nightly-develop,enable=${{ github.ref == 'refs/heads/develop' }} | |
type=ref,event=tag | |
type=match,pattern=tc_v(\d+),group=1 | |
type=match,pattern=tc_v(\d+.\d+),group=1 | |
type=match,pattern=tc_v(\d+.\d+.\d+),group=1 | |
type=match,pattern=tc_v(\d+.\d+.\d+-\S+),group=1 | |
flavor: | | |
prefix=arch_,onlatest=true | |
suffix=_${{ matrix.platform }},onlatest=true | |
- name: Build & push digest docker ${{ matrix.platform }} | |
id: build | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
platforms: ${{ matrix.platform }} | |
push: ${{ github.event_name != 'pull_request' }} | |
labels: ${{ steps.matrix_meta.outputs.labels }} | |
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Export digest | |
run: | | |
mkdir -p /tmp/digests/${{ github.sha }} | |
digest="${{ steps.build.outputs.digest }}" | |
commit_sha="${{ github.sha }}" | |
touch "/tmp/digests/${commit_sha}/${digest#sha256:}" | |
- name: Push docker tags ${{ matrix.platform }} | |
id: push_tags | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
platforms: ${{ matrix.platform }} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.matrix_meta.outputs.tags }} | |
labels: ${{ steps.matrix_meta.outputs.labels }} | |
- name: Upload digest | |
uses: actions/upload-artifact@v3 | |
with: | |
name: digests | |
path: /tmp/digests/${{ github.sha }}/* | |
if-no-files-found: error | |
merge-images: | |
runs-on: ubuntu-latest | |
needs: | |
- build-container_matrix | |
steps: | |
- name: Download digests | |
uses: actions/download-artifact@v3 | |
with: | |
name: digests | |
path: /tmp/digests/${{ github.sha }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker meta | |
id: teddycloud_meta # you'll use this in the next step | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: ${{ env.REGISTRY_IMAGE }} | |
# Docker tags based on the following events/attributes | |
tags: | | |
type=schedule | |
type=schedule,pattern=nightly | |
type=schedule,pattern={{date 'YYYYMMDD'}} | |
type=schedule,pattern={{date 'YYYYMMDD-hhmmss' tz='Germany/Berlin'}} | |
type=ref,event=branch | |
type=ref,event=pr | |
type=sha | |
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/tc_v') }} | |
type=raw,value=nightly,enable=${{ startsWith(github.ref, 'refs/tags/tc_nightly') }} | |
type=raw,value=nightly-develop,enable=${{ github.ref == 'refs/heads/develop' }} | |
type=ref,event=tag | |
type=match,pattern=tc_v(\d+),group=1 | |
type=match,pattern=tc_v(\d+.\d+),group=1 | |
type=match,pattern=tc_v(\d+.\d+.\d+),group=1 | |
type=match,pattern=tc_v(\d+.\d+.\d+-\S+),group=1 | |
- name: Create manifest list and push | |
if: ${{ github.event_name != 'pull_request' }} | |
working-directory: /tmp/digests/${{ github.sha }} | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | |
- name: Inspect image | |
if: ${{ github.event_name != 'pull_request' }} | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.teddycloud_meta.outputs.version }} |