Skip to content

Initial release

Initial release #1

Workflow file for this run

name: Running tests
on:
push:
# branches: [ main ]
pull_request:
jobs:
discover-services:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- name: Discover directories with Dockerfiles
id: services
run: |
echo "services=$(find . -type f -name Dockerfile | xargs -n 1 dirname | uniq | cut -d '/' -f 2 | jq -R -s -c 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT"
- name: Print services with Dockerfiles
run: |
echo "Services with Dockerfiles: ${{ steps.services.outputs.services }}"
outputs:
services: ${{ steps.services.outputs.services }}
build-containers:
needs: discover-services
runs-on: ubuntu-latest
if: needs.discover-services.outputs.services != '[]'
strategy:
matrix:
service: ${{ fromJson(needs.discover-services.outputs.services) }}
permissions:
contents: read
# packages: write
defaults:
run:
working-directory: ${{ matrix.service }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
# - name: Authorize to GitHub Packages
# run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
# - name: Authorize to Github Docker Registry
# run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Check service was changed in the commit
id: check-service-changed
run: |
git diff --quiet ${{ github.event.before }} ${{ github.event.after }} -- .
echo exit-code=$? >> $GITHUB_OUTPUT
shell: bash {0}
continue-on-error: true
- name: Build container
if: steps.check-service-changed.outputs.exit-code != 0
run: |
make build
- name: Check if the current version has already been pushed
id: check-if-pushed
run: |
export GHCR_TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64)
export TAG=$BASE_TAG$(cat VERSION)
echo manifest=$(curl -s -H "Authorization: Bearer ${GHCR_TOKEN}" https://ghcr.io/v2/certat/$(make print)/manifests/$TAG | grep "manifest unknown") >> $GITHUB_OUTPUT
# TODO: environment & manual approval
# - name: Push container
# if: steps.check-if-pushed.outputs.manifest
# run: |
# make push
# echo "ghcr.io/certat/$(make print):$BASE_TAG$(cat VERSION)" > tag.txt
# cat VERSION > version.txt
outputs:
changed: ${{ steps.check-service-changed.outputs.exit-code }}