discourse-release: tag mode #2
No files matched your search
@@ -38,6 +38,19 @@ jobs:
|
|||||||
discord-webhook: ${{ secrets.DISCORD_RELEASE_WEBHOOK }} # optional
|
discord-webhook: ${{ secrets.DISCORD_RELEASE_WEBHOOK }} # optional
|
||||||
```
|
```
|
||||||
|
|
||||||
|
A workflow that creates its release with the job's own token (`secrets.GITHUB_TOKEN`)
|
||||||
|
must announce it itself, as a last step: Gitea starts no workflow for events
|
||||||
|
the Actions bot causes, so `on: release` never fires for such a release.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: coffey-labs/actions/discourse-release@<sha>
|
||||||
|
with:
|
||||||
|
api-key: ${{ secrets.DISCOURSE_RELEASE_KEY }}
|
||||||
|
tag: ${{ github.ref_name }}
|
||||||
|
```
|
||||||
|
|
||||||
|
Both at once is fine: a repo+tag is announced once, whichever runs first.
|
||||||
|
|
||||||
- The repo must be listed in `discourse-release/release-map.json`, the one
|
- The repo must be listed in `discourse-release/release-map.json`, the one
|
||||||
place that maps repos to forum categories.
|
place that maps repos to forum categories.
|
||||||
- `DISCOURSE_RELEASE_KEY` is an org-level secret (coffey-labs and inbuxa)
|
- `DISCOURSE_RELEASE_KEY` is an org-level secret (coffey-labs and inbuxa)
|
||||||
|
|||||||
@@ -11,6 +11,14 @@ inputs:
|
|||||||
description: optional Discord webhook URL; when set, the announcement is also posted there
|
description: optional Discord webhook URL; when set, the announcement is also posted there
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
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:
|
forum:
|
||||||
description: forum base URL
|
description: forum base URL
|
||||||
required: false
|
required: false
|
||||||
@@ -25,6 +33,8 @@ runs:
|
|||||||
FORUM: ${{ inputs.forum }}
|
FORUM: ${{ inputs.forum }}
|
||||||
REPO: ${{ github.repository }}
|
REPO: ${{ github.repository }}
|
||||||
EVENT_PATH: ${{ github.event_path }}
|
EVENT_PATH: ${{ github.event_path }}
|
||||||
|
TAG: ${{ inputs.tag }}
|
||||||
|
GITEA_TOKEN: ${{ github.token }}
|
||||||
ACTION_PATH: ${{ github.action_path }}
|
ACTION_PATH: ${{ github.action_path }}
|
||||||
MAP: ${{ github.action_path }}/release-map.json
|
MAP: ${{ github.action_path }}/release-map.json
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -10,6 +10,19 @@ if [ -z "$category_path" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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")
|
tag=$(jq -r '.release.tag_name' "$EVENT_PATH")
|
||||||
# The category id, looked up anonymously (the category is public); the
|
# The category id, looked up anonymously (the category is public); the
|
||||||
# release-bot key is scoped to creating posts and nothing else.
|
# release-bot key is scoped to creating posts and nothing else.
|
||||||
|
|||||||
Reference in new issue
Block a user