Skip to content

build-cache-hoi4

build-cache-hoi4 #270

Workflow file for this run

name: Build and push game cache
on: repository_dispatch
jobs:
build_cache:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.CWTOOLSBOT_TOKEN }}
steps:
- name: Setup Dotnet for use with actions
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.0.100'
- name: Get event payload
run: |
event_name=$(sudo cat $GITHUB_EVENT_PATH | jq -r '.action')
game_temp=""
echo $event_name
case $event_name in
"build-cache-hoi4") game_temp="hoi4" ;;
"build-cache-stellaris") game_temp="stellaris" ;;
"build-cache-eu4") game_temp="eu4" ;;
"build-cache-ck2") game_temp="ck2" ;;
"build-cache-vic2") game_temp="vic2" ;;
"build-cache-ir") game_temp="ir" ;;
"build-cache-ck3") game_temp="ck3" ;;
*) exit 1 # terminate and indicate error
esac
echo "GAME=$game_temp" >> $GITHUB_ENV
- uses: actions/checkout@v1
with:
ref: ${{ env.GAME }}
fetch-depth: 1
- name: Set git config
run: |
git config --local user.email "[email protected]"
git config --local user.name "cwtools-bot"
- name: Clone game rules
run: |
cd $GITHUB_WORKSPACE/..
git clone --depth=1 https://github.com/cwtools/cwtools-$GAME-config.git cwtools-$GAME-config
cd cwtools-$GAME-config
git fetch
git pull
- name: Clone game files
run: |
cd $GITHUB_WORKSPACE/..
git clone --single-branch --branch $GAME --depth=1 https://cwtools-bot:[email protected]/tboby/cwtools-game-data.git cwtools-game-data
- name: Install CWTools
run: |
dotnet tool install --global -v m CWTools.CLI
- name: Generate cache
run: |
cd $GITHUB_WORKSPACE/../cwtools-game-data
if [ "$GAME" = "stellaris" ]; then
$HOME/.dotnet/tools/cwtools --game stl --directory . --rulespath $GITHUB_WORKSPACE/../cwtools-$GAME-config serialize metadata
mv -v -f stl.cwv.bz2 $GITHUB_WORKSPACE
else
$HOME/.dotnet/tools/cwtools --game $GAME --directory . --rulespath $GITHUB_WORKSPACE/../cwtools-$GAME-config serialize metadata
mv -v -f $GAME.cwv.bz2 $GITHUB_WORKSPACE
fi
- name: Commit and push updated cache
run: |
cd $GITHUB_WORKSPACE
git add .
git commit -m "Update cache file" -a
git fetch
git pull
git push https://cwtools-bot:[email protected]/cwtools/cwtools-cache-files.git --all --follow-tags