diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index bd63f61b5..f97da592d 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -8,11 +8,17 @@ on: required: true default: '[]' type: string + secrets: + DOCKER_USERNAME: + description: 'Dockerhub Username' + required: true + DOCKER_PASSWORD: + description: 'Dockerhub Token' + required: true jobs: build-and-push: runs-on: ubuntu-latest - environment: docker if: ${{ inputs.changedPackages != '[]'}} strategy: fail-fast: false @@ -69,11 +75,12 @@ jobs: key: ${{ runner.os }}-multi-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-multi-buildx + - name: Login to DockerHub uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - name: Read .node-version id: node_version 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..522202cd9 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -8,38 +8,20 @@ on: - 'master' jobs: - analyse-changed-packages: + test: runs-on: ubuntu-latest - outputs: - changedPackages: ${{ steps.changed-packages.outputs.CHANGED_PACKAGES }} steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - name: echo docker_username char length + run: echo "${{ secrets.DOCKER_USERNAME }}" | wc -c - - 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