Skip to content

Base builds off changed directory structure of repo #1

Base builds off changed directory structure of repo

Base builds off changed directory structure of repo #1

Workflow file for this run

name: build-push
on:
push:
jobs:
find-jobs:
name: Find changed directories
runs-on: ubuntu-latest
outputs:
folders: ${{ steps.jobs.outputs.folders }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: jobs
run: |
folders=$(git diff --diff-filter="ACMR" --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs dirname | awk -F '/' '{print $1}' | sort | uniq | grep -Ev "^\." | awk NF | jq -c --raw-input --slurp 'split("\n") | .[0:-1]')
echo "folders=$folders" >> $GITHUB_OUTPUT
get-tags:
needs: [find-jobs]
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.tags.outputs.tags }}
steps:
- uses: actions/checkout@v4
- id: tags
run: |
json_array=$(echo '${{ needs.find-jobs.outputs.folders }}' | jq -rc '.[]')
TAGS=$(while read -r REPO; do
for TAG in $(ls $REPO/.build-args); do
echo '{"context":"'${REPO}'", "image":"'${REPO}':'${TAG}'", "args":"'$(cat ${REPO}/.build-args/${TAG})'"},'
done
done <<< "$json_array")
TAGS=$(echo "[${TAGS%,}]")
echo "tags=$TAGS" >> $GITHUB_OUTPUT
build-push-ar:
needs: [get-tags]
strategy:
matrix:
tags: ${{ fromJson(needs.get-tags.outputs.tags )}}
uses: ./.github/workflows/build-push-ar.yml
with:
image: "internal/${{ matrix.image }}"
context: ${{ matrix.context }}
build-args: ${{ matrix.args }}
permissions:
contents: read
id-token: write
secrets: inherit