-
Notifications
You must be signed in to change notification settings - Fork 779
85 lines (74 loc) · 2.71 KB
/
check-for-generated-files.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
75
76
77
78
79
80
81
82
83
84
85
name: Check for Generated Files
on:
# Triggers the workflow on push or pull request events but only for the dev branch
pull_request:
branches: [dev]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
checkFiles:
name: Check Files
runs-on: ubuntu-latest
steps:
- name: Checkout files
uses: actions/checkout@v2
- name: Check bundle files
id: changed-bundle-files
uses: tj-actions/changed-files@v18.4
with:
files: |
dist/*
index.html
main.bundle.js
main.bundle.js.map
- name: Check documentation changes
id: changed-markdown-doc-files
uses: tj-actions/changed-files@v18.4
with:
files: |
markdown/*.md
- name: Warn when bundle files were changed
id: warn-bundles-changed
if: steps.changed-bundle-files.outputs.any_changed == 'true'
run: |
echo "One or more files in the bundle files were changed." >> warnings.txt
- name: Warn when documentation markdown files were changed
id: warn-markdown-changed
if: steps.changed-markdown-doc-files.outputs.any_changed == 'true'
run: |
echo "One or more files in the markdown documentation were changed." >> warnings.txt
- name: Print Warnings
id: get-warnings
run: |
if [ -f warnings.txt ]
then
echo "::set-output name=has_warnings::true"
else
echo "::set-output name=has_warnings::false"
touch warnings.txt
fi
- name: Get Comment Body
id: get-comment-body
if: steps.get-warnings.outputs.has_warnings == 'true'
run: |
cat warnings.txt > comment.txt
echo "" >> comment.txt
echo "Please do not commit files generated by webpack or generated markdown" >> comment.txt
echo "" >> comment.txt
echo "See [CONTRIBUTING.md](https://github.com/bitburner-official/bitburner-src/blob/dev/doc/CONTRIBUTING.md) for details." >> comment.txt
body=$(cat comment.txt)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
- name: Add github comment on problem
if: steps.get-warnings.outputs.has_warnings == 'true'
uses: peter-evans/commit-comment@v1
with:
body: ${{ steps.get-comment-body.outputs.body }}
- name: Flag as error
if: steps.get-warnings.outputs.has_warnings == 'true'
run: |
COMMIT_WARNINGS=$(cat warnings.txt)
echo "::warning:: $COMMIT_WARNINGS"
exit 1