add speedWalkRecorder package #41
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |