handle promise #82
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: CI/CD | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deps: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
node-version: [14.19.3] | |
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}} | |
REVUE_TOKEN: ${{secrets.REVUE_TOKEN}} | |
REDIS_URL: ${{secrets.REDIS_URL}} | |
REDIS_HOST_PASSWORD: ${{secrets.REDIS_HOST_PASSWORD}} | |
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,REVUE_TOKEN,REDIS_URL,API_PORT,REDIS_HOST_PASSWORD | |
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 REVUE_TOKEN=$REVUE_TOKEN | |
export REDIS_URL=$REDIS_URL | |
export REDIS_HOST_PASSWORD=$REDIS_HOST_PASSWORD | |
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 |