diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..2c05fcf --- /dev/null +++ b/.github/workflows/release.yaml @@ -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 }} diff --git a/script/release b/script/release new file mode 100755 index 0000000..d72c128 --- /dev/null +++ b/script/release @@ -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 +