Skip to content

more robust notification handling #95

more robust notification handling

more robust notification handling #95

name: Production deploy
on:
push:
branches: [ master ]
workflow_dispatch:
jobs:
test-and-deploy:
runs-on: ubuntu-latest
environment: production
services:
postgres:
image: postgres:14
env:
POSTGRES_USER: runner
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: Test
run: go test -v ./...
- name: Build
run: go build -v -o . ./...
- name: Deploy app
run: |
mkdir -p /home/runner/.ssh
ssh-keyscan -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_HOST }} >> /home/runner/.ssh/known_hosts
echo "${{ secrets.SSH_PRIVATE_KEY }}" > /home/runner/.ssh/id_ed25519
chmod 600 /home/runner/.ssh/id_ed25519
scp -P ${{ secrets.SSH_PORT }} withoutings ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:~/bin/withoutings-new
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "set -o allexport; source withoutings.environmentfile; set +o allexport; bin/withoutings-new migrate"
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "rm -f bin/withoutings; mv bin/withoutings-new bin/withoutings; sudo /bin/systemctl restart withoutings"
status_code=$(curl --write-out %{http_code} --silent --output /dev/null ${{ secrets.WEB_URL }}/api/health)
if [[ "$status_code" -ne 200 ]] ; then
echo "FAIL: Health check status changed to $status_code !!!"
exit 1
else
exit 0
fi