-
Notifications
You must be signed in to change notification settings - Fork 10
94 lines (78 loc) · 2.74 KB
/
validate-mpackage.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
86
87
88
89
90
91
92
93
94
name: Validate mpackage file
on: pull_request
jobs:
check-mpackage-contents:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@master
- name: Only one file per PR is allowed
id: check-file-count
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
FILE=$(gh pr view ${{ github.event.pull_request.number }} --json files --jq '.files[].path')
# check only 1 file has been uploaded per PR
if [ `echo "$FILE" |wc -l` -gt 1 ]; then
echo "Error: Only one package file per pull request please."
exit 1
else
echo "Pass: just one file uploaded."
fi
echo "FILE=$FILE" >> $GITHUB_OUTPUT
- name: Unzip the mpackage and check config.lua exists
id: unzip-mpackage-file
run: |
FILE=${{ steps.check-file-count.outputs.FILE }}
echo $FILE
# unzip the mpackage
unzip -q -o $FILE -d unzipped_package
ls -al unzipped_package
#only valid if it has a config.lua
if [ -f "unzipped_package/config.lua" ]; then
echo "Pass: config.lua is present"
else
echo "Error: config.lua is missing."
exit 1
fi
- name: Check config.lua contains all required information
id: check-config-lua
run: |
FILE=${{ steps.check-file-count.outputs.FILE }}
#grep for some vital details
if grep -q "mpackage =" unzipped_package/config.lua; then
echo "Pass: has a valid mpackage name"
else
echo "Error: not a valid mpackage file"
exit 1
fi
if grep -q "title =" unzipped_package/config.lua; then
echo "Pass: has a valid title"
else
echo "Error: does not contain a valid title"
exit 1
fi
if grep -q "version =" unzipped_package/config.lua; then
echo "Pass: config.lua contains a version number"
else
echo "Error: does not contain a version number"
exit 1
fi
if grep -q "created =" unzipped_package/config.lua; then
echo "Pass: has a valid creation date"
else
echo "Error: not a valid creation date"
exit 1
fi
if grep -q "author =" unzipped_package/config.lua; then
echo "Pass: has a valid author name"
else
echo "Error: does not contain a valid author name"
exit 1
fi
if grep -q "description =" unzipped_package/config.lua; then
echo "Pass: has a valid description"
else
echo "Error: does not contain a valid description"
exit 1
fi