-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (68 loc) · 2.53 KB
/
update_cache.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
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