Skip to content

update

update #89

Workflow file for this run

name: CI/CD
on:
push:
branches:
- main
jobs:
deps:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [14.20.0]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, lint and/or test
run: |
yarn
env:
CI: true
build:
needs: deps
runs-on: ubuntu-20.04
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
steps:
-
name: Check Out Repo
uses: actions/checkout@v2
-
name: Login to Docker Hub
uses: docker/login-action@v1
if: ${{env.DOCKERHUB_USERNAME != 0}}
with:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
if: ${{env.DOCKERHUB_USERNAME != 0}}
with:
context: ./
file: ./Dockerfile
push: true
tags: ecency/api:latest
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
deploy:
needs: build
runs-on: ubuntu-20.04
steps:
- name: SSH and deploy node app
uses: appleboy/ssh-action@master
env:
PRIVATE_API_ADDR: ${{secrets.PRIVATE_API_ADDR}}
PRIVATE_API_AUTH: ${{secrets.PRIVATE_API_AUTH}}
HIVESIGNER_CLIENT_SECRET: ${{secrets.HIVESIGNER_CLIENT_SECRET}}
SEARCH_API_ADDR: ${{secrets.SEARCH_API_ADDR}}
SEARCH_API_SECRET: ${{secrets.SEARCH_API_SECRET}}
API_PORT: ${{secrets.API_PORT}}
with:
host: ${{ secrets.SSH_PRODUCTION_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
envs: PRIVATE_API_ADDR,PRIVATE_API_AUTH,HIVESIGNER_CLIENT_SECRET,SEARCH_API_ADDR,SEARCH_API_SECRET,API_PORT
script: |
export PRIVATE_API_ADDR=$PRIVATE_API_ADDR
export PRIVATE_API_AUTH=$PRIVATE_API_AUTH
export HIVESIGNER_CLIENT_SECRET=$HIVESIGNER_CLIENT_SECRET
export SEARCH_API_ADDR=$SEARCH_API_ADDR
export SEARCH_API_SECRET=$SEARCH_API_SECRET
export API_PORT=$API_PORT
cd ~/vision-api
git pull origin main
docker pull ecency/api:latest
docker stack deploy -c docker-compose.yml vision-api
docker system prune -f