Skip to content

Refactor workflow to streamline linking of compiled Groovy files #56

Refactor workflow to streamline linking of compiled Groovy files

Refactor workflow to streamline linking of compiled Groovy files #56

name: "\"Compile\" Groovy Scripts"
on:
push:
branches:
- main
paths:
- '_*.groovy'
- "compiler.py"
- ".github/workflows/they_said_to_compile.yaml"
- "modules/**"
- "post_*.groovy"
jobs:
compile:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install regex
- name: Run Groovy So-Compiler for file format
run: |
# Find groovy files starts with _ on current directory
groovyFiles=$(find . -type f -name "_*.groovy")
function link_file {
local file=$1
local loc=$2
local towindows=$(echo $loc | sed 's/posix/windows/')
if [ -e $loc ]; then
rm $loc
fi
if [ -e $towindows ]; then
rm $towindows
fi
ln -s $file $loc
ln -s $file $towindows
}
# Compile each groovy file
for file in $groovyFiles; do
fbname="$(basename "$file" | sed 's/^_//')"
compiledFile="compiled/$fbname"
psxloc="_posix_$fbname"
cpsxloc="compiled/posix_$fbname"
link_file "$file" "$psxloc"
python3 compiler.py "$file" "$compiledFile"
link_file "$compiledFile" "$cpsxloc"
done
- name: Run Groovy So-Called Compiler for post_ and preset_*.groovy files
run: |
# Find groovy files starts with post_ and preset_ on current directory
groovyFiles=$(find . -type f -name "post_*.groovy")
# Compile each groovy file
for file in $groovyFiles; do
compiledFile="compiled/$(basename "$file")"
python3 compiler.py "$file" "$compiledFile"
done
- name: Commit and Push Changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add compiled
git commit -m "Compile Groovy Scripts"
git push