Skip to content

Update Server

Update Server #4

Workflow file for this run

name: Update Server
on:
workflow_call:
workflow_dispatch:
concurrency:
group: update-${{ github.ref_name == 'main' && 'prod' || 'dev' }}-server
cancel-in-progress: false
jobs:
update:
name: Update Server
runs-on: ubuntu-latest
if: ${{ github.ref_name == 'main' || github.ref_name == 'dev' }}
env:
CONFIG_FILE: ${{ secrets.TMWEB_SSH_PATH }}/${{ github.ref_name == 'main' && 'prod' || 'dev' }}/2014/compose.yaml
steps:
- name: Generate SHA
run: echo "FRONTEND_APPLICATION_SHA=$(echo -n $(date +%s) | shasum -a 256 | tr -d "\n *-")" >> $GITHUB_ENV
- uses: appleboy/ssh-action@master
with:
envs: FRONTEND_APPLICATION_SHA
host: ${{secrets.TMWEB_SSH_HOST}}
username: ${{secrets.TMWEB_SSH_USER}}
key: ${{secrets.TMWEB_SSH_KEY}}
port: ${{secrets.TMWEB_SSH_PORT}}
script: |
docker compose -f ${{ env.CONFIG_FILE }} pull app && \
docker compose -f ${{ env.CONFIG_FILE }} build app && \
docker compose -f ${{ env.CONFIG_FILE }} up app \
--no-deps \
--detach
docker rmi $(docker images --filter "dangling=true" -q --no-trunc) &