Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #7 from thepwagner/dispatch-on-release
Browse files Browse the repository at this point in the history
send repository_dispatch on release
  • Loading branch information
Pete Wagner authored Oct 10, 2020
2 parents c563fea + 9fba192 commit 8db80b9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Release
on:
release:
types: [released]

jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: script/release
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_PAT }}
25 changes: 25 additions & 0 deletions script/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# This script triggers "repository_dispatch" events on an array of dependencies
# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#repository_dispatch
# It's expected these events will be handled by an action-update-go workflow, to open a PR updating the just-released dependency

DOWNSTREAMS=(
thepwagner/action-update-go
thepwagner/action-update-docker
thepwagner/action-update-dockerurl
)

REPO_NAME=$(jq '.repository.full_name' "$GITHUB_EVENT_PATH")
TAG_NAME=$(jq '.release.tag_name' "$GITHUB_EVENT_PATH")
EMPTY_PAYLOAD='{"event_type":"action-update-go-release","client_payload":{"path":"","version":""}}'

EVENT_PAYLOAD=$(echo "$EMPTY_PAYLOAD" | jq ".client_payload.path = github.com/$REPO_NAME" | jq ".client_payload.version = $TAG_NAME")
AUTH_HEADER="Authorization: token $GITHUB_TOKEN"
for DS in "${DOWNSTREAMS[@]}"; do
echo "$DS"
curl -H "$AUTH_HEADER" \
-d "$EVENT_PAYLOAD" \
"https://api.github.com/repos/${DS}/dispatches"
done

0 comments on commit 8db80b9

Please sign in to comment.