11name : Automated test for PRs
22
3+ # Run any time a PR is created or modified
34on :
45 pull_request :
56 types : [opened, reopened, synchronize]
67
8+ env :
9+ # The folder that Docusaurus hosts static files (images) from
10+ STATIC_FOLDER : ' static'
11+ # Images to ignore for image use checks
12+ IGNORE_IMAGES : ' img/site'
13+
714jobs :
815
16+ # Get files that are added or changed in this PR
917 getChangedFiles :
1018 runs-on : ubuntu-latest
1119 outputs :
1220 files : ${{ steps.changed-markdown-files.outputs.all_changed_files }}
1321 steps :
14- # Get files that are added or changed in this PR
1522 # https://github.com/marketplace/actions/changed-files
1623 - name : Get all changed MD/MDX files
1724 id : changed-markdown-files
@@ -29,30 +36,36 @@ jobs:
2936 echo "$file was changed"
3037 done
3138
39+ # Test the changed files
3240 test :
3341 runs-on : ubuntu-latest
3442 needs : getChangedFiles
35- # if: ${{ needs.getChangedFiles.outputs.files != '' }}
43+ if : ${{ needs.getChangedFiles.outputs.files != '' }}
3644 env :
37- ALL_CHANGED_FILES : ${{ needs.checkChangedFiles.outputs.files }}
45+ # Create a comma-separated list of changed MD and MDX files
46+ ALL_CHANGED_FILES : ${{ join(needs.checkChangedFiles.outputs.files, ',') }}
3847 steps :
3948 # Clone the repo and install dependencies
40- # - uses: actions/checkout@v2
41- # - uses: actions/setup-node@v1
42- # with:
43- # node-version: 20
49+ - uses : actions/checkout@v2
50+ - uses : actions/setup-node@v1
51+ with :
52+ node-version : 20
4453 # - run: npm ci
4554
4655 # Clone tests from https://gitlab.com/nomadic-labs/doclib
4756 # Uses https://github.com/marketplace/actions/any-clone-repo
48- # - name: Clone test repo
49- # uses: chihqiang/checkout-action@main
50- # with:
51- # repo: 'https://gitlab.com/nomadic-labs/doclib.git'
52- # branch: 'main'
57+ - name : Clone test repo
58+ uses : chihqiang/checkout-action@main
59+ with :
60+ repo : https://gitlab.com/nomadic-labs/doclib.git
61+ branch : main
62+ dest : doclib
63+ - name : Install test repo dependencies
64+ working-directory : doclib
65+ run : npm ci
5366
5467 # Run tests
55- - run : |
56- for file in ${ALL_CHANGED_FILES}; do
57- echo "$file was changed"
58- done
68+ - name : Run used image check
69+ working-directory : doclib
70+ run : npm run usedImages -- --baseFolder=${{ github.workspace }} --docFiles=${{ env.ALL_CHANGED_FILES }} --imageFolder=${{ env.STATIC_FOLDER }}
71+
0 commit comments