Skip to content

Commit

Permalink
Merge pull request #175 from toniebox-reverse-engineering/develop
Browse files Browse the repository at this point in the history
Next Version
  • Loading branch information
SciLor authored Aug 25, 2024
2 parents 8e82613 + ea2cb27 commit 827cd47
Show file tree
Hide file tree
Showing 79 changed files with 5,799 additions and 1,569 deletions.
34 changes: 14 additions & 20 deletions .github/workflows/build_commit_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ name: Make web and commit

on:
workflow_dispatch:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest

outputs:
tcw_commit_hash: ${{ steps.get_commit_hash.outputs.commit_hash }}

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -90,25 +94,15 @@ jobs:
echo "No changes to commit and push."
fi
- name: Get current branch for next step
id: get_branch
run: echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV

- name: Trigger publish_docker_matrix.yml
uses: actions/github-script@v6
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const event_type = 'trigger-publish-docker'; // Matches the repository_dispatch trigger
const client_payload = { "branch": process.env.branch };
await github.repos.createDispatchEvent({
owner,
repo,
event_type,
client_payload
});
- name: Get Last Commit Hash
id: get_tcw_commit_hash
run: echo "tcw_commit_hash=$(git rev-parse HEAD)" >> $GITHUB_ENV

- name: Wait for a few seconds # to avoid missing commit in followup steps
run: sleep 10

build_docker:
uses: ./.github/workflows/publish_docker_matrix.yml
needs: build
uses: ./.github/workflows/publish_docker_matrix.yml
with:
tcw_commit_hash: ${{ needs.build.outputs.tcw_commit_hash }}
24 changes: 18 additions & 6 deletions .github/workflows/publish_docker_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,33 @@ name: Docker Image Publish Matrix (All)
on:
workflow_dispatch:
workflow_call:
inputs:
tcw_commit_hash:
description: "Commit hash from the teddycloud_web build job"
type: string
required: false
default: "HEAD"

push:
branches:
- master
- develop
- master
- develop
tags:
- tc_nightly*
- tc_v*.*.*
- tc_nightly*
- tc_v*.*.*
pull_request:
branches: [ "master", "develop" ]
branches: ["master", "develop"]

jobs:
debian:
uses: ./.github/workflows/publish_docker_matrix_debian.yml
with:
tcw_commit_hash: ${{ inputs.tcw_commit_hash }}
ubuntu:
uses: ./.github/workflows/publish_docker_matrix_ubuntu.yml
with:
tcw_commit_hash: ${{ inputs.tcw_commit_hash }}
alpine:
uses: ./.github/workflows/publish_docker_matrix_alpine.yml
uses: ./.github/workflows/publish_docker_matrix_alpine.yml
with:
tcw_commit_hash: ${{ inputs.tcw_commit_hash }}
189 changes: 103 additions & 86 deletions .github/workflows/publish_docker_matrix_alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ name: Docker Image Publish Matrix (Alpine)
on:
workflow_dispatch:
workflow_call:
inputs:
tcw_commit_hash:
description: "Commit hash from the teddycloud_web build job"
type: string
required: false
default: "HEAD"

# permissions are needed if pushing to ghcr.io
permissions:
permissions:
packages: write

env:
Expand All @@ -16,31 +22,41 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x,linux/386]
platform:
[
linux/amd64,
linux/arm/v6,
linux/arm/v7,
linux/arm64/v8,
linux/ppc64le,
linux/s390x,
linux/386,
]
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
- uses: actions/checkout@v4
with:
submodules: recursive
ref: ${{ inputs.tcw_commit_hash }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: 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: Login to GHCR
uses: docker/login-action@v3
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: |
- 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'}}
Expand All @@ -56,85 +72,86 @@ jobs:
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 }}_alpine,onlatest=true
flavor: |
prefix=arch_,onlatest=true
suffix=_${{ matrix.platform }}_alpine,onlatest=true
- name: Build & push digest docker ${{ matrix.platform }}
id: build
uses: docker/build-push-action@v5
with:
context: .
file: DockerfileAlpine
platforms: ${{ matrix.platform }}
push: true
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: Build & push digest docker ${{ matrix.platform }}
id: build
uses: docker/build-push-action@v5
with:
context: .
file: DockerfileAlpine
platforms: ${{ matrix.platform }}
push: true
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: Platform name strip for filename
id: platform_strip
run: |
platform=$(echo "${{ matrix.platform }}" | tr '/' '_')
echo "platform=$platform"
echo "platform=$platform" >> $GITHUB_OUTPUT
- name: Run docker image test
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker run -e DOCKER_TEST=1 --platform ${{ matrix.platform }} --name teddyCloud-test ${{ env.REGISTRY_IMAGE }}@${{ steps.build.outputs.digest }}
continue-on-error: ${{ matrix.platform == 'x' }}
- name: Extract release zip
run: |
docker cp teddyCloud-test:/tmp/teddycloud.zip /tmp/teddycloud.${{ steps.platform_strip.outputs.platform }}.release.zip
docker rm teddyCloud-test
continue-on-error: ${{ matrix.platform == 'x' }}
- name: Platform name strip for filename
id: platform_strip
run: |
platform=$(echo "${{ matrix.platform }}" | tr '/' '_')
echo "platform=$platform"
echo "platform=$platform" >> $GITHUB_OUTPUT
- name: Run docker image test
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker run -e DOCKER_TEST=1 --platform ${{ matrix.platform }} --name teddyCloud-test ${{ env.REGISTRY_IMAGE }}@${{ steps.build.outputs.digest }}
continue-on-error: ${{ matrix.platform == 'x' }}
- name: Extract release zip
run: |
docker cp teddyCloud-test:/tmp/teddycloud.zip /tmp/teddycloud.${{ steps.platform_strip.outputs.platform }}.alpine.release.zip
docker rm teddyCloud-test
continue-on-error: ${{ matrix.platform == 'x' }}

- 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: 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@v5
with:
context: .
file: DockerfileAlpine
platforms: ${{ matrix.platform }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.matrix_meta.outputs.tags }}
labels: ${{ steps.matrix_meta.outputs.labels }}

- name: Push docker tags ${{ matrix.platform }}
id: push_tags
uses: docker/build-push-action@v5
with:
context: .
file: DockerfileAlpine
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@v4
with:
name: digests-alpine-${{ steps.platform_strip.outputs.platform }}
path: /tmp/digests/${{ github.sha }}/*
if-no-files-found: error
- name: Upload release file
uses: actions/upload-artifact@v4
with:
name: release-${{ steps.platform_strip.outputs.platform }}-alpine
path: /tmp/teddycloud.${{ steps.platform_strip.outputs.platform }}.alpine.release.zip
if-no-files-found: error

- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/${{ github.sha }}/*
if-no-files-found: error
- name: Upload release file
uses: actions/upload-artifact@v3
with:
name: release-${{ steps.platform_strip.outputs.platform }}
path: /tmp/teddycloud.${{ steps.platform_strip.outputs.platform }}.release.zip
if-no-files-found: error

merge-images:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: digests
pattern: digests-alpine-*
merge-multiple: true
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
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand Down Expand Up @@ -170,7 +187,7 @@ jobs:
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 ' *)
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
if: ${{ github.event_name != 'pull_request' }}
run: |
Expand Down
Loading

0 comments on commit 827cd47

Please sign in to comment.