Skip to content

tidy

tidy #4558

Workflow file for this run

name: Build Docker Images
on:
push:
branches:
- master
- dev
- dev-pl
- dev-v2
- dev-*
- staging
- dev-*
paths-ignore:
- ".github/workflows/**"
- "examples/**"
- "proto/**"
- "tools/**/*.sh"
- "README.md"
- "traefik.yml"
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_TAG: ${{github.ref_name == 'master' && 'latest' || github.ref_name}}
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set target tags
id: set-tags-matrix
run: |
TAGS_JSON=$(ls Dockerfiles | jq -cnR '[inputs | select(length>0)]')
echo "matrix=$TAGS_JSON" >> $GITHUB_OUTPUT
echo "### Discovered Containers :whale:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
for title in $(echo $TAGS_JSON | jq -r '.[]'); do
echo "* $title" | tr '-' ' ' >> $GITHUB_STEP_SUMMARY
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "#### Raw" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```json' >> $GITHUB_STEP_SUMMARY
echo "$TAGS_JSON" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
outputs:
matrix: ${{ steps.set-tags-matrix.outputs.matrix }}
# wait-for-checks:
# runs-on: ubuntu-latest
# steps:
# - name: Wait for tests to succeed
# uses: lewagon/wait-on-check-action@v1.3.4
# with:
# ref: ${{ github.ref }}
# check-name: checks
# repo-token: ${{ secrets.GITHUB_TOKEN }}
# wait-interval: 10
build-and-push-base-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.5.1
with:
tags: type=raw,value=${{env.IMAGE_TAG}}
images: ${{ env.REGISTRY }}/slntopp/nocloud/base
- name: Log in to the Container registry
uses: docker/login-action@v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6.7.0
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-and-push:
runs-on: ubuntu-latest
needs: [prepare, build-and-push-base-image]
strategy:
matrix:
tag: ${{fromJson(needs.prepare.outputs.matrix)}}
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.5.1
with:
tags: type=raw,value=${{env.IMAGE_TAG}}
images: ${{ env.REGISTRY }}/slntopp/nocloud/${{matrix.tag}}
- name: Log in to the Container registry
uses: docker/login-action@v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6.7.0
id: build
with:
context: .
file: Dockerfiles/${{matrix.tag}}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: IMAGE_TAG=${{env.IMAGE_TAG}}
- name: Summary
run: |
echo "### :whale: Published new image" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Digest:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "${{ steps.build.outputs.imageid }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo 'docker pull ${{ env.REGISTRY }}/slntopp/nocloud/${{matrix.tag}}:${{env.IMAGE_TAG}}' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "> Operator would automatically pull new image, otherwise use the command above" >> $GITHUB_STEP_SUMMARY