From 30e3fbd112de261ec80544ee5db03481411223aa Mon Sep 17 00:00:00 2001 From: Manuel Ruck Date: Sun, 15 Oct 2023 13:31:18 +0200 Subject: [PATCH] =?UTF-8?q?ci:=20=F0=9F=91=B7=20fix=20pipeline=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Ruck --- .github/workflows/build-and-push.yaml | 55 ++++++++++++++++++++------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index aa650be10..ebd59b47f 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -17,33 +17,62 @@ on: jobs: analyse-changed-packages: - uses: demokratie-live/democracy-development/.github/workflows/analyse-changed-packages.yaml@feature/changelog + runs-on: ubuntu-latest + outputs: + changed: ${{ steps.changed-packages.outputs.CHANGED }} + changedPackages: ${{ steps.changed-packages.outputs.CHANGED_PACKAGES }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 - push: + - uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: false + + - run: echo SINCE=$(git rev-list --tags --max-count=1) >> $GITHUB_OUTPUT + id: since + + - run: | + pnpm list -r --json --filter "...[$SINCE]" | jq '[.[] | select(.private == false) | {name, path}]' > ./tmp.json + echo CHANGED_PACKAGES=$(jq '[.[] | .name]' ./tmp.json) >> $GITHUB_OUTPUT + id: changed-packages + env: + SINCE: ${{ steps.since.outputs.SINCE }} + + build-and-push: runs-on: ubuntu-latest environment: docker needs: [analyse-changed-packages] - if: ${{ needs.analyse-changed-packages.outputs.changed != '[]' && needs.analyse-changed-packages.outputs.changed != '' }} + if: ${{ needs.analyse-changed-packages.outputs.changedPackages != '[]'}} strategy: fail-fast: false matrix: - package: ${{fromJson(needs.analyse-changed-packages.outputs.changed)}} + package: ${{fromJson(needs.analyse-changed-packages.outputs.changedPackages)}} steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: false + - run: echo "package=${{ matrix.package }}" - name: get directory for package id: get-directory run: | - # Variablen setzen - matrix_package="${{ matrix.package }}" - changed_packages_json='${{ needs.analyse-changed-packages.outputs.changedPackages }}' - - # Verzeichnis mit jq finden - directory=$(echo "$changed_packages_json" | jq -r --arg package "$matrix_package" '.[] | select(.package == $package) | .directory') + directory=$(pnpm ls -r --json --filter $MATRIX_PACKAGE | jq '.[0] | .path') # Ausgabe - echo "$directory" echo "directory=$directory" >> $GITHUB_OUTPUT - - name: Checkout - uses: actions/checkout@v4 + env: + MATRIX_PACKAGE: ${{ matrix.package }} + + - run: echo "directory=${{ steps.get-directory.outputs.directory }}" + - name: Docker meta id: meta uses: docker/metadata-action@v5