forked from kekru/struktogrammeditor
-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (44 loc) · 1.56 KB
/
Copy pathrelease-notes-to-github.yml
File metadata and controls
48 lines (44 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Writes an existing GitHub Release description from release-notes/<tag>.md
# Manual: Actions → “Sync release notes to GitHub” → Run workflow → tag e.g. v1.0.7
name: Sync release notes to GitHub
on:
workflow_dispatch:
inputs:
tag:
description: "Git tag of the release (e.g. v1.0.7)"
required: true
default: "v1.0.7"
type: string
permissions:
contents: read
jobs:
patch-body:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set release body from file
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ inputs.tag }}
run: |
set -euo pipefail
FILE="release-notes/${TAG}.md"
if [[ ! -f "$FILE" ]]; then
echo "::error::No file $FILE on the current branch."
exit 1
fi
REPO="${{ github.repository }}"
REL_JSON=$(curl -sS -H "Authorization: Bearer $GH_TOKEN" -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${REPO}/releases/tags/${TAG}")
REL_URL=$(echo "$REL_JSON" | jq -er .url)
BODY=$(jq -n --rawfile body "$FILE" '{body: $body}')
curl -sS -f -X PATCH \
-H "Authorization: Bearer $GH_TOKEN" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"$REL_URL" \
-d "$BODY"
echo "Release ${TAG}: description set from ${FILE}."