Skip to content

Setting up new deployment workflow #1

Setting up new deployment workflow

Setting up new deployment workflow #1

Workflow file for this run

name: Build and Deploy Docker Image
on:
push:
branches:
- docker
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node and NPM
uses: actions/setup-node@v3
with:
node-version: 18.14.0
- name: Install Client NPM Packages
run: npm ci
working-directory: client
- name: Compile Client
run: npm run production
working-directory: client
- name: Install WSS NPM Packages
run: npm ci
working-directory: wss
- name: Compile WSS
run: npm run production
working-directory: wss
- name: Build HTTP Docker Image
run: docker build -f Dockerfile.http -t codewithkyle/tabletopper-http:prod .
- name: Save HTTP Docker Image as Tarball
run: docker save -o tabletopper-http.tar codewithkyle/tabletopper-http:prod
- name: Build WSS Docker Image
run: docker build -f Dockerfile.wss -t codewithkyle/tabletopper-wss:prod .
- name: Save WSS Docker Image as Tarball
run: docker save -o tabletopper-wss.tar codewithkyle/tabletopper-wss:prod
- name: Load SSH Key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
- name: Deploy
run: scp -o StrictHostKeyChecking=no ./tabletopper-http.tar ./tabletoper-wss.tar ${{ secrets.USERNAME }}@${{ secrets.HOST }}:~/
- name: Post Deployment
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
PORT: 22
KEY: ${{ secrets.SSH_KEY }}
script: docker load -i ~/tabletopper-wss.tar && docker load -i ~/tabletopper-http.tar
- name: Purge cache
uses: nathanvaughn/actions-cloudflare-purge@master
if: success()
with:
cf_zone: ${{ secrets.CLOUDFLARE_ZONE }}
cf_auth: ${{ secrets.CLOUDFLARE_AUTH_KEY }}