forked from mdn/content
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (63 loc) · 2.13 KB
/
pr-filecheck.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
74
# Note that this workflow uses `get-diff-action` which is important.
# It gives us an environment variable called `GIT_DIFF` which is a string
# that is a list of file paths.
# If you want to do what this workflow does on your laptop you can simulate
# it like this:
#
# yarn filecheck $(git diff main... '--diff-filter=AM' --name-only | rg '\.(png|svg|jpe?g|gif|webp)')
#
# That way, you can behave on your laptop like, this action behaves here.
name: PR Filecheck
on:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v3
id: git_diff_content
with:
SUFFIX_FILTER: |
.png
.jpeg
.jpg
.gif
.svg
.webp
PREFIX_FILTER: files/
ABSOLUTE: true
- uses: actions/checkout@v2
if: steps.git_diff_content.outputs.diff
with:
repository: mdn/yari
path: yari
- name: Setup Node.js environment
if: steps.git_diff_content.outputs.diff
uses: actions/[email protected]
with:
node-version: "12"
- name: Get yarn cache directory path
if: steps.git_diff_content.outputs.diff
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/[email protected]
if: steps.git_diff_content.outputs.diff
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install all yarn packages
if: steps.git_diff_content.outputs.diff
run: |
cd yari
yarn --frozen-lockfile
- name: Check changed files
if: steps.git_diff_content.outputs.diff
run: |
export CONTENT_ROOT=$(pwd)/files
# Need to run from the yari we've cleanly cloned.
cd yari
yarn filecheck ${{ env.GIT_DIFF }}