-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·66 lines (57 loc) · 2.68 KB
/
release-check.yaml
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
name: Semantic Release Check 📝
on:
pull_request:
branches:
- master
permissions: write-all
jobs:
PR-checks:
# https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/using-self-hosted-runners-in-a-workflow
runs-on: ubuntu-latest
name: Semantic Release Check 📝
steps:
- name: 📀 Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 🖥️ Setup Env
uses: ./.github/workflows/install
- name: 🔬 Check semantic versioning
id: semantic-release
run: |
GITHUB_REF=${{ github.head_ref }}
npx semantic-release --no-ci --dry-run --plugins @semantic-release/commit-analyzer,@semantic-release/release-notes-generator --branches ${{ github.head_ref }} > output.txt
OUTPUT=$(cat output.txt | base64 -w 0)
echo "::set-output name=releaseNote::$OUTPUT"
- name: 📝 Report semantic versioning
uses: actions/github-script@v3
if: ${{ steps.semantic-release.outputs.releaseNote != '' }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// build release note
const fromBuffer = Buffer.from('${{ steps.semantic-release.outputs.releaseNote }}', 'base64').toString('utf8');
const matchRegex = /^[[0-9:\sAMPM]+\]\s\[semantic-release\].*$/;
const releaseNote = fromBuffer.split('\n').filter((line) => !line.match(matchRegex));
const res = releaseNote.join('\n');
if (!releaseNote.length || !res) {
return;
}
const body = `The new semantic report is: \n ${res}`;
// get last comment
const comments = await github.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const alreadyCommented = comments.data.find((comment) => comment.body === body);
if (alreadyCommented) {
return;
}
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body,
})