Skip to content

Add BloCamLimb schematics #2

Add BloCamLimb schematics

Add BloCamLimb schematics #2

name: TeaCon 2022 deploy to test server
on:
push:
branches: [ dev ]
paths:
- "2022/**"
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-22.04
steps:
- name: Checkout the Repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check Differences
id: diff
env:
HEAD: ${{ github.sha }}
BASE: ${{ github.event.before }}
run: |
# calculate diff count
git_flags=`[[ -z $BASE ]] && echo ls-files || echo diff --name-only $HEAD $BASE`
mods_diff=`git $git_flags -- 2022/mod-list-test.json | wc -l`
assets_diff=`git $git_flags -- 2022/assets 2022/pack.mcmeta | wc -l`
data_diff=`git $git_flags -- 2022/data 2022/pack.mcmeta | wc -l`
serverconfig_diff=`git $git_flags -- 2022/serverconfig | wc -l`
config_diff=`git $git_flags -- 2022/config | wc -l`
# set diff count output
echo "::set-output name=mods::$mods_diff"
echo "::set-output name=assets::$assets_diff"
echo "::set-output name=data::$data_diff"
echo "::set-output name=serverconfig::$serverconfig_diff"
echo "::set-output name=config::$config_diff"
- name: Handle Mods
if: steps.diff.outputs.mods > 0
env:
RUN: ${{ github.run_number }}
run: |
# rename mod list json
cp 2022/mod-list-test.json mod-list-test-$RUN.json
- name: Handle Assets
if: steps.diff.outputs.assets > 0
env:
RUN: ${{ github.run_number }}
run: |
# zip assets
cd 2022; zip -r9Xo ../assets-test-$RUN.zip assets pack.mcmeta
- name: Handle Data
if: steps.diff.outputs.data > 0
env:
RUN: ${{ github.run_number }}
run: |
# zip data
cd 2022; zip -r9Xo ../data-test-$RUN.zip data pack.mcmeta
- name: Handle Config
if: steps.diff.outputs.config > 0
env:
RUN: ${{ github.run_number }}
run: |
# zip config
cd 2022; zip -r9Xo ../config-test-$RUN.zip config
- name: Handle Server Config
if: steps.diff.outputs.serverconfig > 0
env:
RUN: ${{ github.run_number }}
run: |
# zip server config
cd 2022; zip -r9Xo ../serverconfig-test-$RUN.zip serverconfig
- name: Deploy to Longjing Server
env:
HEAD: ${{ github.sha }}
RUN: ${{ github.run_number }}
SSH_PRIVATE_KEY: ${{ secrets.TEACON_LONGJING_SSH_PRIVATE_KEY }}
run: |
# deploy ssh private key
cat > ~/id_ecdsa <<< $SSH_PRIVATE_KEY
chmod 0600 ~/id_ecdsa # good permissions
mkdir -p ~/.ssh && touch ~/.ssh/known_hosts
ssh-keyscan -H 2022.teacon.cn >> ~/.ssh/known_hosts
# copy to longjing server
[email protected]:deploy/
echo Considering git ref $HEAD with build number $RUN
[[ -f mod-list-test-$RUN.json ]] && scp -i ~/id_ecdsa mod-list-test-$RUN.json $dest
[[ -f assets-test-$RUN.zip ]] && scp -i ~/id_ecdsa assets-test-$RUN.zip $dest
[[ -f data-test-$RUN.zip ]] && scp -i ~/id_ecdsa data-test-$RUN.zip $dest
[[ -f config-test-$RUN.zip ]] && scp -i ~/id_ecdsa config-test-$RUN.zip $dest
[[ -f serverconfig-test-$RUN.zip ]] && scp -i ~/id_ecdsa serverconfig-test-$RUN.zip $dest
# run deploy command
ssh -i ~/id_ecdsa [email protected] flock deploy.lock bash deploy-test.sh $RUN
echo Finished deploying to the test server.