Skip to content

fix race condition

fix race condition #41

Workflow file for this run

name: production deploy
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
# test:
# ...
deploy:
runs-on: ubuntu-latest
environment: production
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# needs: test
steps:
- name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/prod.key
chmod 600 ~/.ssh/prod.key
cat >>~/.ssh/config <<END
Host prod
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/prod.key
StrictHostKeyChecking no
END
env:
SSH_USER: ${{ secrets.PROD_SSH_USER }}
SSH_KEY: ${{ secrets.PROD_SSH_KEY }}
SSH_HOST: ${{ secrets.PROD_SSH_HOST }}
- name: Get latest source
run: ssh prod 'cd /mux && git fetch && git pull'
- name: Restart the server
run: ssh prod 'systemctl restart chatmux'