-
-
Notifications
You must be signed in to change notification settings - Fork 176
51 lines (51 loc) · 2.02 KB
/
test-template-changes.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
######################################
## Custom Web Almanac GitHub action ##
######################################
#
# This Action generates the dynamic templates. It also then takes a copy
# of the templates folder, and then checks out main branch and regenerates the
# templates and compares the two. If run from a pull request it adds a comment
# showing the diffs.
#
# Note it does not run a full test of the website as that will be completed by
# the test_website.yml GitHub Action.
#
# This Action is useful to check impact of dependency upgrades (e.g. if
# prettier version change results in different HTML being generated), since we
# do not store generated templates in Git and so cannot otherwise see these
# changes. Changes can then be accepted or investigated further before merging.
#
name: Test Template Changes
on:
workflow_dispatch:
pull_request:
paths:
- '**/package.json'
- '**/package-lock.json'
jobs:
build:
name: Build and Test Template Changes
runs-on: ubuntu-20.04
if: github.repository == 'HTTPArchive/almanac.httparchive.org'
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js for use with actions
uses: actions/setup-node@v4
with:
node-version: '16'
- name: Test Template Changes
run: ./src/tools/scripts/test_template_changes.sh
- name: 'Comment PR'
uses: actions/github-script@v7
if: github.event_name == 'pull_request' && env.PR_COMMENT != ''
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# yamllint disable rule:line-length
script: |
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
// Unescape any escaped comments so code blocks appear correctly
const pr_comment = process.env.PR_COMMENT.replace(/%0A/g,'\n').replace(/%0D/g,'\r').replace(/%27/g,"'").replace(/%22/g,'"').replace(/%25/g,'%');
github.rest.issues.createComment({ issue_number, owner, repo, body: pr_comment });