feat: add loggin (#4) #5
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: Kratos Readonly Traits - Build Containers | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
env: | |
KRATOS_READONLY_TRAITS_IMAGE: ghcr.io/clinia/kratos-readonly-traits | |
jobs: | |
build: | |
strategy: | |
fail-fast: true # In case one of the jobs fails, the other jobs will be cancelled | |
matrix: | |
arch: | |
[ | |
{ runs-on: buildjet-4vcpu-ubuntu-2204, platform: linux/amd64 }, | |
{ runs-on: buildjet-8vcpu-ubuntu-2204-arm, platform: linux/arm64 }, | |
] | |
name: Build - ${{matrix.arch.platform}} | |
runs-on: ${{matrix.arch.runs-on}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.KRATOS_READONLY_TRAITS_IMAGE }} | |
tags: | | |
type=edge | |
type=sha,event=branch,prefix=edge-,suffix=-{{date 'YYYYMMDDHHmmss'}},format=short | |
type=semver,pattern={{version}} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Github Docker Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push by digest | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ matrix.arch.platform }} | |
labels: ${{ steps.meta.outputs.labels }} | |
outputs: type=image,name=${{ env.KRATOS_READONLY_TRAITS_IMAGE }},push-by-digest=true,name-canonical=true,push=true | |
secrets: | | |
"npm_token=${{ secrets.CLINIA_CI_GITHUB_TOKEN }}" | |
cache-from: type=registry,ref=user/app:latest | |
cache-to: type=inline | |
- name: Export digest | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${digest#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v3 | |
with: | |
name: digests | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
merge: | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
steps: | |
- name: Download digests | |
uses: actions/download-artifact@v3 | |
with: | |
name: digests | |
path: /tmp/digests | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.KRATOS_READONLY_TRAITS_IMAGE }} | |
tags: | | |
type=edge | |
type=sha,event=branch,prefix=edge-,suffix=-{{date 'YYYYMMDDHHmmss'}},format=short | |
type=semver,pattern={{version}} | |
- name: Login to Github Docker Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create manifest list and push | |
working-directory: /tmp/digests | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.KRATOS_READONLY_TRAITS_IMAGE }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.KRATOS_READONLY_TRAITS_IMAGE }}:${{ steps.meta.outputs.version }} |