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
# Runs mantra check to write the overview of reference changes in a PR comment.
name: mantra-pr
on:
pull_request:
permissions:
issues: write
pull-requests: write
jobs:
mantra-pr:
runs-on: ubuntu-latest
container:
image: manuelhatzl/mantra:main
env:
BRANCH_NAME: ${{ github.base_ref }}
steps:
- uses: actions/checkout@v3
with:
repository: 'mhatzl/evident-wiki'
path: './req_folder'
sparse-checkout: 5-Requirements
- uses: actions/checkout@v3
with:
path: './proj_folder'
- name: check
id: check
# '&>' to get stderr and stdout in one file, so error logs get included in output.
# Uses ' ' (U+2002) instead of regular space for output, because GitHub output cannot handle regular spaces
# see: https://stackoverflow.com/questions/59191913/how-do-i-get-the-output-of-a-specific-step-in-github-actions
run: |
mantra check --branch-name=$BRANCH_NAME ./req_folder ./proj_folder &> check_overview.md
output="$(cat check_overview.md)"
output="${output//\'/\\\'}"
output="${output//\"/\\\"}"
output="${output//$'\n'/\\\\n}"
output="${output// / }"
cat check_overview.md
echo "check-overview=$output" >> $GITHUB_OUTPUT
- name: comment
uses: actions/github-script@v6
with:
script: |
const check_overview = '${{ steps.check.outputs.check-overview }}'.replaceAll('\\n', '\n')
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: check_overview
})