diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index 45d23e781..40bfb0ff7 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -1,57 +1,23 @@ name: Docker – Build and Push on: - workflow_dispatch: - push: - tags: - - '*' - pull_request: - paths: - - 'services/**' - branches: - - 'master' + workflow_call: + inputs: + changedPackages: + description: 'Changed Packages' + required: true + default: '[]' + type: string 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 }} - build-and-push: runs-on: ubuntu-latest environment: docker - needs: [analyse-changed-packages] - if: ${{ needs.analyse-changed-packages.outputs.changedPackages != '[]'}} + if: ${{ inputs.changedPackages != '[]'}} strategy: fail-fast: false matrix: - package: ${{fromJson(needs.analyse-changed-packages.outputs.changedPackages)}} + package: ${{fromJson(inputs.changedPackages)}} steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml new file mode 100644 index 000000000..edfeccc46 --- /dev/null +++ b/.github/workflows/pull_request.yaml @@ -0,0 +1,48 @@ +name: Pull Request + +on: + workflow_dispatch: + pull_request: + paths: + - 'services/**' + branches: + - 'master' + +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 }} + + build-and-push: + uses: .github/workflows/build-and-push.yaml + needs: analyse-changed-packages + with: + changed: ${{ needs.analyse-changed-packages.outputs.changed }} + changedPackages: ${{ needs.analyse-changed-packages.outputs.changedPackages }}