Skip to content

Commit

Permalink
automate prod deploy (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan-rash authored Feb 28, 2024
1 parent 1ec2c0c commit 3b32c50
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

- name: Get changes to UI directory
id: ui-edited
uses: tj-actions/changed-files@v34
uses: tj-actions/changed-files@v42
with:
files: natster-io/**
build-ui:
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/ui_prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: 'UI - Prod Env'
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"

jobs:
check-ui:
runs-on: ubuntu-latest
name: Check UI for edits
outputs:
status: ${{ steps.ui-edited.outputs.any_changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get changes to UI directory
id: ui-edited
uses: tj-actions/changed-files@v42
with:
files: natster-io/**

build-ui:
runs-on: ubuntu-latest
name: Builds UI if edits found
needs: check-ui
if: needs.check-ui.outputs.status
steps:
-
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Build ui
working-directory: ./natster-io
run: |
curl -fsSL https://get.pnpm.io/install.sh | SHELL=bash sh -
~/.local/share/pnpm/pnpm install
~/.local/share/pnpm/pnpm build-only --outDir server/dist
-
name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.0'
-
name: Build server
working-directory: ./natster-io/server
run: |
go build -o natster-ui-server
-
name: Archive server binaries
uses: actions/upload-artifact@v4
with:
name: web_server
retention-days: 1
path: |
./natster-io/server/natster-ui-server
deployment:
runs-on: ubuntu-latest
name: Deploy to Prod
needs: build-ui
environment:
name: Prod
url: https://natster.io
steps:
-
name: Download server artifact
uses: actions/download-artifact@v4
with:
name: web_server
-
name: Tailscale
uses: tailscale/github-action@v2
with:
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
tags: tag:natster
-
name: Stop Prod Server
run: |
ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" root@natster-ui.pig-bee.ts.net systemctl stop natster-ui-prod.service
-
name: Update Prod server on host
run: |
scp -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" natster-ui-server root@natster-ui.pig-bee.ts.net:/usr/local/bin/natster-ui-server
-
name: Restart Prod Server
run: |
ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" root@natster-ui.pig-bee.ts.net systemctl start natster-ui-prod.service

0 comments on commit 3b32c50

Please sign in to comment.