Skip to content

Commit

Permalink
ci: 👷 modulize analyse services action
Browse files Browse the repository at this point in the history
Signed-off-by: Manuel Ruck <[email protected]>
  • Loading branch information
Manuel Ruck committed Oct 21, 2023
1 parent a08ed09 commit dc4ce66
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 64 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/get-changed-services.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
38 changes: 7 additions & 31 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
38 changes: 5 additions & 33 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dc4ce66

Please sign in to comment.