From dc4ce664562dfeb5cc27dabd3ea56cd7e9f58e4b Mon Sep 17 00:00:00 2001 From: Manuel Ruck Date: Sat, 21 Oct 2023 17:19:39 +0200 Subject: [PATCH] =?UTF-8?q?ci:=20=F0=9F=91=B7=20modulize=20analyse=20servi?= =?UTF-8?q?ces=20action?= 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 | 7 ++++ .github/workflows/get-changed-services.yaml | 38 +++++++++++++++++++++ .github/workflows/pull_request.yaml | 38 ++++----------------- .github/workflows/release.yaml | 38 +++------------------ 4 files changed, 57 insertions(+), 64 deletions(-) create mode 100644 .github/workflows/get-changed-services.yaml diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index bd63f61b5..4107a89e3 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -8,6 +8,13 @@ on: required: true default: '[]' type: string + secrets: + DOCKERHUB_USERNAME: + description: 'Dockerhub Username' + required: true + DOCKERHUB_TOKEN: + description: 'Dockerhub Token' + required: true jobs: build-and-push: diff --git a/.github/workflows/get-changed-services.yaml b/.github/workflows/get-changed-services.yaml new file mode 100644 index 000000000..8ba398d19 --- /dev/null +++ b/.github/workflows/get-changed-services.yaml @@ -0,0 +1,38 @@ +name: Get Changed Packages + +on: + workflow_call: + outputs: + CHANGED_PACKAGES: + value: ${{ jobs.analyse-changed-packages.outputs.changedPackages }} + +jobs: + analyse-changed-packages: + runs-on: ubuntu-latest + outputs: + changedPackages: ${{ steps.changed-packages.outputs.CHANGED_PACKAGES }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: false + + - run: | + SINCE=$(git rev-list --tags --max-count=1) + echo SINCE=$SINCE >> $GITHUB_OUTPUT + echo SINCE=$SINCE + id: since + + - run: | + pnpm list -r --json --filter "...[$SINCE]" | jq '[.[] | select(.private == false) | {name, path}]' > ./tmp.json + CHANGED_PACKAGES=$(jq '[.[] | .name]' ./tmp.json) + echo CHANGED_PACKAGES=$CHANGED_PACKAGES >> $GITHUB_OUTPUT + echo CHANGED_PACKAGES=$CHANGED_PACKAGES + id: changed-packages + env: + SINCE: ${{ steps.since.outputs.SINCE }} diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 399d89d24..f654d686d 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -8,38 +8,14 @@ on: - 'master' jobs: - analyse-changed-packages: - runs-on: ubuntu-latest - outputs: - changedPackages: ${{ steps.changed-packages.outputs.CHANGED_PACKAGES }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: pnpm/action-setup@v2 - with: - version: 8 - run_install: false - - - run: | - SINCE=$(git rev-list --tags --max-count=1) - echo SINCE=$SINCE >> $GITHUB_OUTPUT - echo SINCE=$SINCE - id: since - - - run: | - pnpm list -r --json --filter "...[$SINCE]" | jq '[.[] | select(.private == false) | {name, path}]' > ./tmp.json - CHANGED_PACKAGES=$(jq '[.[] | .name]' ./tmp.json) - echo CHANGED_PACKAGES=$CHANGED_PACKAGES >> $GITHUB_OUTPUT - echo CHANGED_PACKAGES=$CHANGED_PACKAGES - id: changed-packages - env: - SINCE: ${{ steps.since.outputs.SINCE }} + analyse-changed-services: + uses: ./.github/workflows/get-changed-services.yaml build-and-push: uses: ./.github/workflows/build-and-push.yaml - needs: analyse-changed-packages + needs: analyse-changed-services with: - changedPackages: ${{ needs.analyse-changed-packages.outputs.changedPackages }} + changedPackages: ${{ needs.analyse-changed-services.outputs.CHANGED_PACKAGES }} + secrets: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 253a77d5d..ed9d855b4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -26,46 +26,18 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} jobs: - analyse-changed-packages: - 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: 0 - - - uses: pnpm/action-setup@v2 - with: - version: 8 - run_install: false - - - run: | - SINCE=$(git rev-list --tags --max-count=1) - echo SINCE=$SINCE >> $GITHUB_OUTPUT - echo SINCE=$SINCE - id: since - - - run: | - pnpm list -r --json --filter "...[$SINCE]" | jq '[.[] | select(.private == false) | {name, path}]' > ./tmp.json - CHANGED_PACKAGES=$(jq '[.[] | .name]' ./tmp.json) - echo CHANGED_PACKAGES=$CHANGED_PACKAGES >> $GITHUB_OUTPUT - echo CHANGED_PACKAGES=$CHANGED_PACKAGES - id: changed-packages - env: - SINCE: ${{ steps.since.outputs.SINCE }} + analyse-changed-services: + uses: ./.github/workflows/get-changed-services.yaml release: - needs: [analyse-changed-packages] + needs: [analyse-changed-services] runs-on: ubuntu-latest - if: ${{ needs.analyse-changed-packages.outputs.changedPackages != '[]'}} + if: ${{ needs.analyse-changed-services.outputs.CHANGED_PACKAGES != '[]'}} strategy: fail-fast: false max-parallel: 1 matrix: - package: ${{fromJson(needs.analyse-changed-packages.outputs.changedPackages)}} + package: ${{fromJson(needs.analyse-changed-services.outputs.CHANGED_PACKAGES)}} steps: - name: Checkout Repo uses: actions/checkout@v4