-
Notifications
You must be signed in to change notification settings - Fork 60.3k
64 lines (54 loc) · 2.56 KB
/
test-changed-content.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
name: Test changed content
# **What it does**: Runs the vitest tests for changed and deleted content files.
# **Why we have it**: Use GitHub Actions to run tests on changed content files.
# **Who does it impact**: Docs engineering, open-source engineering contributors.
on:
pull_request:
branches:
# This is important! If you make a PR against a megabranch, you
# might actually want to delete a file without setting up a
# redirect in its place. But if it's going into `main` we'll
# want to make sure that doesn't happen.
- main
paths:
- 'content/**'
permissions:
contents: read
jobs:
test-changed-content:
runs-on: ${{ fromJSON('["ubuntu-latest", "ubuntu-20.04-xl"]')[github.repository == 'github/docs-internal'] }}
if: ${{ github.repository == 'github/docs-internal' || github.repository == 'github/docs' }}
steps:
# Each of these ifs needs to be repeated at each step to make sure the required check still runs
# Even if if doesn't do anything
- name: Check out repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
# See https://github.com/tj-actions/changed-files#on-pull_request-
fetch-depth: 2
- uses: ./.github/actions/node-npm-setup
- uses: ./.github/actions/get-docs-early-access
if: ${{ github.repository == 'github/docs-internal' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_READPUBLICKEY }}
- uses: ./.github/actions/cache-nextjs
- name: Run build script
run: npm run build
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@40853de9f8ce2d6cfdc73c1b96f14e22ba44aec4 # v45.0.0
with:
# No need to escape the file names because we make the output of
# tj-actions/changed-files be set as an environment variable. Not
# as a direct input to the line of bash that uses it.
# See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
safe_output: false
files: 'content/**'
# Necessary so we can know what the old name was when a
# content file was renamed.
output_renamed_files_as_deleted_and_added: true
- name: Run tests
env:
CHANGED_FILES: ${{ steps.changed-files.outputs.modified_files }}
DELETED_FILES: ${{ steps.changed-files.outputs.deleted_files }}
run: npm test -- src/content-render/tests/render-changed-and-deleted-files.js