Skip to content

Commit 54265d8

Browse files
ci: use different github tokens for release and dispatch another repo workflow
1 parent d7758f8 commit 54265d8

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

utils/webassembly/distribute-latest-toolchain.sh

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,6 @@ fi
3131
artifacts_url=$(echo $latest_run | jq .artifacts_url --raw-output)
3232
head_sha=$(echo $latest_run | jq .head_sha --raw-output)
3333

34-
dispatch_release_event() {
35-
local release_id=$1
36-
local body=$(cat <<EOS
37-
{
38-
"event_type": "release_created",
39-
"client_payload": {
40-
"toolchain_channel": "$channel",
41-
"ref": "$head_sha",
42-
"release_id": "$release_id"
43-
}
44-
}
45-
EOS
46-
)
47-
48-
github --request POST --fail \
49-
--url "${gh_api}/repos/swiftwasm/swiftwasm-buildbot/dispatches" \
50-
--data "$body"
51-
}
52-
5334
get_artifact_url() {
5435
local name=$1
5536
github $artifacts_url --fail | jq ".artifacts[] | select(.name == \"$name\") | .archive_download_url" | sed 's/\"//g'
@@ -248,6 +229,28 @@ for package in ${release_packages[@]}; do
248229
upload_tarball $release_id "$package"
249230
done
250231

251-
dispatch_release_event "$release_id"
232+
dispatch_release_event() {
233+
local release_id=$1
234+
local body=$(cat <<EOS
235+
{
236+
"event_type": "release_created",
237+
"client_payload": {
238+
"toolchain_channel": "$channel",
239+
"ref": "$head_sha",
240+
"release_id": "$release_id"
241+
}
242+
}
243+
EOS
244+
)
245+
246+
curl --header "authorization: Bearer $BUILDBOT_GITHUB_TOKEN" \
247+
--request POST --fail \
248+
--url "${gh_api}/repos/swiftwasm/swiftwasm-buildbot/dispatches" \
249+
--data "$body"
250+
}
251+
252+
if [[ ! -z "$BUILDBOT_GITHUB_TOKEN" ]]; then
253+
dispatch_release_event "$release_id"
254+
fi
252255

253256
popd

0 commit comments

Comments
 (0)