discourse-release: announce a given tag, for releases made by the job's own token
Gitea starts no workflow for events caused by the Actions bot, so a release created with GITHUB_TOKEN never fires 'on: release'. With 'tag:' the action fetches that release itself; drafts are skipped.
This commit is contained in:
1 parent
3df56d16a5
commit
1f0c7971d6
3 files changed
+36
No files matched your search
@@ -11,6 +11,14 @@ inputs:
|
||||
description: optional Discord webhook URL; when set, the announcement is also posted there
|
||||
required: false
|
||||
default: ""
|
||||
tag:
|
||||
description: >-
|
||||
announce the release with this tag instead of the triggering release
|
||||
event. Needed in a workflow that creates its release with the job's own
|
||||
token: Gitea does not start workflows for events the Actions bot causes,
|
||||
so `on: release` never fires for those releases.
|
||||
required: false
|
||||
default: ""
|
||||
forum:
|
||||
description: forum base URL
|
||||
required: false
|
||||
@@ -25,6 +33,8 @@ runs:
|
||||
FORUM: ${{ inputs.forum }}
|
||||
REPO: ${{ github.repository }}
|
||||
EVENT_PATH: ${{ github.event_path }}
|
||||
TAG: ${{ inputs.tag }}
|
||||
GITEA_TOKEN: ${{ github.token }}
|
||||
ACTION_PATH: ${{ github.action_path }}
|
||||
MAP: ${{ github.action_path }}/release-map.json
|
||||
run: |
|
||||
|
||||
@@ -10,6 +10,19 @@ if [ -z "$category_path" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "${TAG:-}" ]; then
|
||||
# Called with a tag (a release made by the job's own token): fetch it and
|
||||
# treat it as the event, so everything below is the same either way.
|
||||
base="${CI_SERVER_INTERNAL:-$GITHUB_SERVER_URL}"
|
||||
EVENT_PATH=$(mktemp)
|
||||
curl -fsS -H "Authorization: token $GITEA_TOKEN" "$base/api/v1/repos/$REPO/releases/tags/$TAG" |
|
||||
jq '{release: .}' > "$EVENT_PATH"
|
||||
fi
|
||||
if [ "$(jq -r '.release.draft // false' "$EVENT_PATH")" = true ]; then
|
||||
echo "release is a draft; not announcing"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
tag=$(jq -r '.release.tag_name' "$EVENT_PATH")
|
||||
# The category id, looked up anonymously (the category is public); the
|
||||
# release-bot key is scoped to creating posts and nothing else.
|
||||
|
||||
Reference in new issue
Block a user