Dispatch Overlay PR #56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Dispatch Overlay PR | |
| on: | |
| workflow_run: | |
| workflows: ["Publish charts to repo"] | |
| types: | |
| - completed | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| dispatch: | |
| name: Dispatch overlay workflow | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: ubuntu-latest | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| - name: Authenticate to overlays repository | |
| id: octo-sts | |
| uses: octo-sts/action@f603d3be9d8dd9871a265776e625a27b00effe05 # v1.1.1 | |
| with: | |
| scope: shopware-redstone/paas-backend-overlays | |
| identity: "shopware-helm-charts-dispatch" | |
| - name: Send repository_dispatch | |
| env: | |
| GH_TOKEN: ${{ steps.octo-sts.outputs.token }} | |
| run: | | |
| set -euo pipefail | |
| OWNER="${GITHUB_REPOSITORY%/*}" | |
| REPO="${GITHUB_REPOSITORY#*/}" | |
| HEAD_SHA="${{ github.event.workflow_run.head_sha }}" | |
| CHARTS=$(git diff --name-only "${HEAD_SHA}^" "${HEAD_SHA}" -- charts/*/Chart.yaml | awk -F/ '{print $2}' | sort -u) | |
| if [ -z "$CHARTS" ]; then | |
| echo "No chart releases detected." | |
| exit 0 | |
| fi | |
| for CHART in $CHARTS; do | |
| case "$CHART" in | |
| shopware|shopware-operator) ;; | |
| *) continue ;; | |
| esac | |
| VERSION=$(awk -F': *' '$1 == "version" { print $2; exit }' "charts/$CHART/Chart.yaml") | |
| TAG_PREFIX="$CHART" | |
| if [ "$CHART" = "shopware-operator" ]; then | |
| TAG_PREFIX="operator" | |
| fi | |
| SOURCE_REF="${TAG_PREFIX}-${VERSION}" | |
| gh api repos/shopware-redstone/paas-backend-overlays/dispatches \ | |
| -f event_type='overlay_workflow' \ | |
| -f client_payload[repository_owner]="$OWNER" \ | |
| -f client_payload[repository]="$REPO" \ | |
| -f client_payload[chart]="$CHART" \ | |
| -f client_payload[source_ref]="$SOURCE_REF" \ | |
| -f client_payload[target_version]="$VERSION" | |
| done |