Skip to content

Commit ff94818

Browse files
committed
review: switch to workflow_dispatch for the trigger
1 parent 315635b commit ff94818

File tree

2 files changed

+28
-58
lines changed

2 files changed

+28
-58
lines changed

.github/workflows/build-wasm-internal.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,5 @@ jobs:
168168
pr_head_ref: ${{ github.event.pull_request.head.ref }}
169169
build_run_id: ${{ github.run_id }}
170170
client_repo: "bitwarden/clients"
171-
client_event_type: "sdk-breaking-change-check"
172171
client_label: "typescript"
173172
client_workflow: "sdk-breaking-change-check.yml"

.github/workflows/detect-breaking-changes.yml

Lines changed: 28 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ on:
2323
description: "Target client repository (e.g., 'bitwarden/clients')"
2424
required: true
2525
type: string
26-
client_event_type:
27-
description: "Repository dispatch event type"
28-
required: true
29-
type: string
3026
client_label:
3127
description: "Client label for display purposes"
3228
required: true
@@ -35,6 +31,10 @@ on:
3531
description: "Target workflow filename in client repo"
3632
required: true
3733
type: string
34+
client_branch:
35+
description: "The branch to target on the client repo"
36+
type: string
37+
default: "sdk-warn-on-breaking-changes"
3838

3939
permissions:
4040
contents: read
@@ -52,9 +52,9 @@ jobs:
5252
working-directory: .
5353
env:
5454
_CLIENT_REPO: ${{ inputs.client_repo }}
55-
_EVENT_TYPE: ${{ inputs.client_event_type }}
5655
_CLIENT_LABEL: ${{ inputs.client_label }}
5756
_WORKFLOW_NAME: ${{ inputs.client_workflow }}
57+
_BRANCH_NAME: ${{ inputs.client_branch }}
5858
_MAX_RETRIES: 3
5959

6060
steps:
@@ -80,45 +80,19 @@ jobs:
8080
echo " SDK Version: $SDK_VERSION"
8181
echo " Source Run ID: $SOURCE_RUN_ID"
8282
83-
- name: Prepare dispatch payload
84-
id: payload
83+
- name: Prepare workflow inputs
84+
id: inputs
8585
env:
8686
PR_NUMBER: ${{ steps.context.outputs.pr_number }}
8787
SDK_VERSION: ${{ steps.context.outputs.sdk_version }}
88-
PR_HEAD_SHA: ${{ steps.context.outputs.pr_head_sha }}
8988
SOURCE_RUN_ID: ${{ steps.context.outputs.source_run_id }}
9089
GITHUB_REPOSITORY: ${{ github.repository }}
9190
run: |
92-
# Create payload JSON
93-
PAYLOAD=$(jq -n \
94-
--arg pr_number "$PR_NUMBER" \
95-
--arg sdk_version "$SDK_VERSION" \
96-
--arg source_repo "$GITHUB_REPOSITORY" \
97-
--arg workflow_context "$_WORKFLOW_NAME" \
98-
--arg client_label "$_CLIENT_LABEL" \
99-
--arg pr_head_sha "$PR_HEAD_SHA" \
100-
--arg pr_base_ref "main" \
101-
--arg comment_id "" \
102-
--arg run_id "$SOURCE_RUN_ID" \
103-
--arg artifact_name "sdk-internal" \
104-
'{
105-
pr_number: $pr_number,
106-
sdk_version: $sdk_version,
107-
source_repo: $source_repo,
108-
workflow_context: $workflow_context,
109-
client_label: $client_label,
110-
pr_head_sha: $pr_head_sha,
111-
pr_base_ref: $pr_base_ref,
112-
comment_id: $comment_id,
113-
artifacts_info: {
114-
run_id: $run_id,
115-
artifact_name: $artifact_name
116-
}
117-
}')
118-
119-
echo "payload<<EOF" >> $GITHUB_OUTPUT
120-
echo "$PAYLOAD" >> $GITHUB_OUTPUT
121-
echo "EOF" >> $GITHUB_OUTPUT
91+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
92+
echo "sdk_version=$SDK_VERSION" >> $GITHUB_OUTPUT
93+
echo "source_repo=$GITHUB_REPOSITORY" >> $GITHUB_OUTPUT
94+
echo "artifacts_run_id=$SOURCE_RUN_ID" >> $GITHUB_OUTPUT
95+
echo "artifact_name=sdk-internal" >> $GITHUB_OUTPUT
12296
12397
- name: Log in to Azure
12498
uses: bitwarden/gh-actions/azure-login@main
@@ -141,7 +115,7 @@ jobs:
141115
app-id: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-ID }}
142116
private-key: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-KEY }}
143117
owner: ${{ github.repository_owner }}
144-
permission-contents: write
118+
permissions-actions: write
145119
repositories: |
146120
clients
147121
sdk-internal
@@ -191,36 +165,33 @@ jobs:
191165
192166
echo "✅ Initial comment created/updated"
193167
194-
- name: Trigger client repository dispatch and watch
168+
- name: Trigger client workflow dispatch and watch
195169
id: trigger-dispatch-and-watch
196170
timeout-minutes: 15
197171
env:
198172
GH_TOKEN: ${{ steps.app-token.outputs.token }}
199-
PAYLOAD: ${{ steps.payload.outputs.payload }}
200-
SDK_VERSION: ${{ steps.context.outputs.sdk_version }}
173+
PR_NUMBER: ${{ steps.inputs.outputs.pr_number }}
174+
SDK_VERSION: ${{ steps.inputs.outputs.sdk_version }}
175+
SOURCE_REPO: ${{ steps.inputs.outputs.source_repo }}
176+
ARTIFACTS_RUN_ID: ${{ steps.inputs.outputs.artifacts_run_id }}
177+
ARTIFACT_NAME: ${{ steps.inputs.outputs.artifact_name }}
201178
run: |
202-
echo "🚀 Triggering $_WORKFLOW_NAME in $_CLIENT_REPO..."
179+
echo "🚀 Triggering ${_WORKFLOW_NAME} in ${_CLIENT_REPO} via workflow_dispatch..."
203180
204-
# Step 1: Dispatch the workflow
181+
# Step 1: Trigger workflow via workflow_dispatch
205182
RETRY_COUNT=0
206183
DISPATCH_SUCCESS=false
207184
208185
while [ $RETRY_COUNT -lt $_MAX_RETRIES ]; do
209186
RETRY_COUNT=$((RETRY_COUNT + 1))
210187
echo "🔄 Attempt $RETRY_COUNT of $_MAX_RETRIES for $_CLIENT_REPO..."
211188
212-
# Create the complete dispatch payload
213-
DISPATCH_PAYLOAD=$(jq -n \
214-
--arg event_type "$_EVENT_TYPE" \
215-
--argjson client_payload "$PAYLOAD" \
216-
'{
217-
event_type: $event_type,
218-
client_payload: $client_payload
219-
}')
220-
221-
if echo "$DISPATCH_PAYLOAD" | gh api repos/$_CLIENT_REPO/dispatches \
222-
--method POST \
223-
--input -; then
189+
if gh workflow run $_WORKFLOW_NAME --repo $_CLIENT_REPO --ref "$_BRANCH_NAME" \
190+
-f pr_number="$PR_NUMBER" \
191+
-f sdk_version="$SDK_VERSION" \
192+
-f source_repo="$SOURCE_REPO" \
193+
-f artifacts_run_id="$ARTIFACTS_RUN_ID" \
194+
-f artifact_name="$ARTIFACT_NAME"; then
224195
225196
echo "✅ Successfully triggered $_CLIENT_REPO ($_CLIENT_LABEL)"
226197
echo "✅ **$_CLIENT_REPO**: $_WORKFLOW_NAME triggered - [Monitor Progress](https://github.com/$_CLIENT_REPO/actions)" >> $GITHUB_STEP_SUMMARY
@@ -247,7 +218,7 @@ jobs:
247218
MAX_RUN_LIST_RETRIES=10
248219
WORKFLOW_RUN_ID=""
249220
250-
JQ_FILTER='.[] | select(.status as $s | (["requested", "queued", "in_progress", "waiting"] | contains([$s])) and (.displayTitle | contains("'"$SDK_VERSION"'")) and (.name | startswith("SDK breaking change check"))) | .databaseId'
221+
JQ_FILTER='.[] | select(.status as $s | (["requested", "queued", "in_progress", "waiting"] | contains([$s])) and (.displayTitle | contains("'"$SDK_VERSION"'")) and (.name | contains("SDK breaking change check"))) | .databaseId'
251222
252223
while
253224
sleep 5

0 commit comments

Comments
 (0)