-
Notifications
You must be signed in to change notification settings - Fork 1.1k
73 lines (64 loc) · 2.08 KB
/
preview_link.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
63
64
65
66
67
68
69
70
71
72
73
name: Post preview link
on:
pull_request:
paths:
- 'content/en/**.md'
permissions:
contents: read
pull-requests: write
# Stop the current running job if a new push is made to the PR
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
preview-link:
if: contains(github.head_ref, '/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Python
uses: actions/[email protected]
with:
python-version: '3.10'
- run: pip install Mako docutils
- name: Find changed files
id: changed_files
uses: tj-actions/changed-files@v42
with:
include_all_old_new_renamed_files: true
- name: Generate links
env:
branch: ${{ github.head_ref }}
DELETED_FILES: ${{ steps.changed_files.outputs.deleted_files }}
RENAMED_FILES: ${{ steps.changed_files.outputs.renamed_files }}
MODIFIED_FILES: ${{ steps.changed_files.outputs.modified_files }}
ADDED_FILES: ${{ steps.changed_files.outputs.added_files }}
id: comment_body
run: |
python local/bin/py/preview_links.py --deleted="${DELETED_FILES}" \
--renamed="${RENAMED_FILES}" \
--modified="${MODIFIED_FILES}" \
--added="${ADDED_FILES}"
- name: Render template
id: template
uses: chuhlomin/[email protected]
with:
template: .github/preview-links-template.md
- name: Find existing comment
uses: peter-evans/[email protected]
id: find_comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: "Preview links ("
- name: Post comment
uses: peter-evans/[email protected]
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find_comment.outputs.comment-id }}
edit-mode: replace
body: ${{ steps.template.outputs.result }}