-
Notifications
You must be signed in to change notification settings - Fork 778
62 lines (57 loc) · 2.09 KB
/
list-changed-pages.yml
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
name: List Changed Pages
on:
pull_request:
branches:
- main
paths:
- "content/**/*"
permissions:
actions: read
checks: read
contents: read
issues: write
pull-requests: write
jobs:
post-files-changed-comment:
name: "Post files changed comment"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get all changed markdown files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: content/**/*.{md,mdx}
- name: Build comment body
id: build-comment-body
env:
CHANGED_FILES: ${{ steps.changed-files.outputs.any_changed }}
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
shopt -s extglob # enable extended globbing
OUTPUT=""
if [ ${CHANGED_FILES} == 'true' ]; then
OUTPUT="| original | preview |%0A| ------ | ------ |%0A"
for file in ${ALL_CHANGED_FILES}
do
FILE_PATH=${file//+([0-9])-/} # remove numeric prefixes
FILE_PATH=${FILE_PATH#content\/} # remove "content/"
FILE_PATH=${FILE_PATH%.mdx} # remove ".mdx"
FILE_PATH=${FILE_PATH%index} # remove "index"
BRANCH_NAME=${BRANCH_NAME:0:28} # shorten branch name for preview link to a maximum of 28 characters
OUTPUT+="| [${file}](https://www.prisma.io/docs/${FILE_PATH}) | [${file}](https://${BRANCH_NAME//\//-}.docs-51g.pages.dev/${FILE_PATH}) |%0A"
done
else
OUTPUT="No files changed."
fi
echo "::set-output name=body::$OUTPUT"
shopt -u extglob # disable extended globbing
- name: Post comment
uses: ./.github/actions/create-or-update-comment
with:
pull-request: ${{ github.event.pull_request.number }}
body: ${{ steps.build-comment-body.outputs.body }}
body-includes: "original | preview"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}