feat: adjust AMX Mod X 'instantspawner' plugin #196
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: Continuous Deployment | |
on: | |
push: | |
branches: [main] | |
jobs: | |
sync-gaming-server-files: | |
name: Deploy the gaming server files | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup OpenSSH | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.VPS_GAMESERVER_OPENSSH_PRIVATE_KEY }}" > ~/.ssh/${{ secrets.VPS_GAMESERVER_OPENSSH_ID }} | |
chmod 600 ~/.ssh/${{ secrets.VPS_GAMESERVER_OPENSSH_ID }} | |
ssh-keyscan ${{ secrets.VPS_HOSTNAME }} >> ~/.ssh/known_hosts | |
shell: bash | |
- name: Generate the 'mapcycle.txt' file | |
run: ls dodserver/serverfiles/dod/maps/*.bsp | awk -F'/' '{ print $(NF) }' | sed 's/\.bsp$//' | shuf > dodserver/serverfiles/dod/mapcycle.txt | |
shell: bash | |
- name: Set random default map and max players for LinuxGSM | |
run: | | |
DEFAULT_MAP=$(shuf -n 1 dodserver/serverfiles/dod/mapcycle.txt) | |
export VPS_GAMESERVER_CONFIG_DEFAULT_MAP="$DEFAULT_MAP" | |
export VPS_GAMESERVER_CONFIG_MAX_PLAYERS="${{ vars.VPS_GAMESERVER_CONFIG_MAX_PLAYERS }}" | |
envsubst '$VPS_GAMESERVER_CONFIG_DEFAULT_MAP,$VPS_GAMESERVER_CONFIG_MAX_PLAYERS' < dodserver/lgsm/config-lgsm/dodserver/dodserver.cfg.template > dodserver/lgsm/config-lgsm/dodserver/dodserver.cfg | |
rm -f dodserver/lgsm/config-lgsm/dodserver/dodserver.cfg.template | |
shell: bash | |
- name: Set hostname, RCON password, and download URL for the gaming server | |
run: | | |
export VPS_GAMESERVER_CONFIG_HOSTNAME="${{ vars.VPS_GAMESERVER_CONFIG_HOSTNAME }}" | |
export VPS_GAMESERVER_CONFIG_RCON_PASSWORD="${{ secrets.VPS_GAMESERVER_CONFIG_RCON_PASSWORD }}" | |
export VPS_GAMESERVER_CONFIG_DOWNLOAD_URL="${{ vars.VPS_GAMESERVER_CONFIG_DOWNLOAD_URL }}" | |
envsubst '$VPS_GAMESERVER_CONFIG_HOSTNAME,$VPS_GAMESERVER_CONFIG_RCON_PASSWORD,$VPS_GAMESERVER_CONFIG_DOWNLOAD_URL' < dodserver/serverfiles/dod/dodserver.cfg.template > dodserver/serverfiles/dod/dodserver.cfg | |
rm -f dodserver/serverfiles/dod/dodserver.cfg.template | |
shell: bash | |
- name: Set admin and moderator users for AMX Mod X | |
run: | | |
export VPS_GAMESERVER_CONFIG_AMX_ADMINS="${{ vars.VPS_GAMESERVER_CONFIG_AMX_ADMINS }}" | |
envsubst '$VPS_GAMESERVER_CONFIG_AMX_ADMINS' < dodserver/serverfiles/dod/addons/amxmodx/configs/users.ini.template > dodserver/serverfiles/dod/addons/amxmodx/configs/users.ini | |
rm -f dodserver/serverfiles/dod/addons/amxmodx/configs/users.ini.template | |
shell: bash | |
- name: Set execute permissions for the gaming server files | |
run: find dodserver/serverfiles/dod -type f -exec chmod 755 {} \; | |
shell: bash | |
- name: Synchronize the gaming server files | |
run: rsync -e "ssh -i ~/.ssh/${{ secrets.VPS_GAMESERVER_OPENSSH_ID }}" -avvzP --delete --exclude='.*' ${{ secrets.VPS_GAMESERVER_RSYNC_SOURCE_PATH }} ${{ secrets.VPS_GAMESERVER_USERNAME }}@${{ secrets.VPS_HOSTNAME }}:${{ secrets.VPS_GAMESERVER_RSYNC_DEST_PATH }} | |
shell: bash | |
restart-gaming-server: | |
name: Restart the gaming server | |
runs-on: ubuntu-latest | |
needs: [sync-gaming-server-files] | |
steps: | |
- name: Setup OpenSSH | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.VPS_GAMESERVER_OPENSSH_PRIVATE_KEY }}" > ~/.ssh/${{ secrets.VPS_GAMESERVER_OPENSSH_ID }} | |
chmod 600 ~/.ssh/${{ secrets.VPS_GAMESERVER_OPENSSH_ID }} | |
ssh-keyscan ${{ secrets.VPS_HOSTNAME }} >> ~/.ssh/known_hosts | |
shell: bash | |
- name: Execute the restart command through OpenSSH | |
run: ssh -i ~/.ssh/${{ secrets.VPS_GAMESERVER_OPENSSH_ID }} ${{ secrets.VPS_GAMESERVER_USERNAME }}@${{ secrets.VPS_HOSTNAME }} -p 22 "${{ secrets.VPS_GAMESERVER_BINARY }} restart" | |
shell: bash |