Build and Deploy Staging #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy | |
on: # todo: deploy is tag triggered | |
workflow_dispatch: | |
workflow_run: | |
workflows: | |
- "Build and Test" | |
branches: [main] | |
types: | |
- "completed" | |
permissions: | |
issues: read | |
pull-requests: read | |
actions: write | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- run: npm ci | |
- run: npm run build | |
docker: | |
name: Build and Push Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install SSH key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.SSH_KEY }} | |
name: id_rsa | |
known_hosts: ${{ secrets.KNOWN_HOSTS }} | |
config: ${{ secrets.CONFIG }} # ssh_config; optional | |
if_key_exists: fail # replace / ignore / fail; optional (defaults to fail) | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build docker image | |
uses: docker/build-push-action@v5 | |
with: | |
file: ./Dockerfile | |
load: true | |
push: false | |
tags: wa-connector:latest # todo: this is properly tagged/versioned | |
- name: push image and restart services | |
# 1. push image to target | |
# 2. recreate container | |
# 3. cleanup images | |
run: | | |
docker save wa-connector:latest | ssh target docker load | |
ssh target docker compose up -d | |
ssh target docker image prune -f |