split deployment and build statges

This commit is contained in:
Pavel Murygin 2021-06-17 13:20:58 +03:00
parent 34e48a5021
commit 62417a8b86
2 changed files with 33 additions and 21 deletions

View File

@ -4,23 +4,11 @@ on:
push:
branches:
- master
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
### extract branch name
- name: Extract branch name
if: github.event_name != 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
id: extract_branch
- name: Extract branch name
if: github.event_name == 'pull_request'
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: Use Node.js 14
@ -72,13 +60,9 @@ jobs:
run: echo ${{ steps.docker_build.outputs.digest }}
### Deploy
- name: Deploy dashboard@master to DigitalOcean via SSH
uses: appleboy/ssh-action@v0.1.3
- name: Invoke deployment workflow
uses: benc-uk/workflow-dispatch@v1
with:
HOST: ${{ secrets.DASHBOARD_HOST }}
USERNAME: ${{ secrets.DASHBOARD_USERNAME }}
KEY: ${{ secrets.DASHBOARD_SSHKEY }}
script: |
docker pull fluencelabs/dashboard:${{ env.VERSION }}
docker rm -f dashboard
docker run -d --name dashboard -p443:443 -p80:80 -v caddy_data:/data fluencelabs/dashboard:${{ env.VERSION }}
workflow: Some Workflow
token: ${{ secrets.PERSONAL_TOKEN }}
inputs: '{ "version": ${{ env.VERSION }} }'

28
.github/workflows/deploy.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: build and deploy prod
on:
workflow_dispatch:
inputs:
version:
description: "Version of docker container to deploy"
required: false
default: 'latest'
jobs:
build:
runs-on: ubuntu-latest
steps:
### Set version
- run: echo "CONTAINER_TAG=fluencelabs/dashboard:${{ github.event.inputs.version }}" >> $GITHUB_ENV
### Deploy
- name: Deploy dashboard@master to DigitalOcean via SSH
uses: appleboy/ssh-action@v0.1.3
with:
HOST: ${{ secrets.DASHBOARD_HOST }}
USERNAME: ${{ secrets.DASHBOARD_USERNAME }}
KEY: ${{ secrets.DASHBOARD_SSHKEY }}
script: |
docker pull ${{ env.CONTAINER_TAG }}
docker rm -f dashboard
docker run -d --name dashboard -p443:443 -p80:80 -v caddy_data:/data ${{ env.CONTAINER_TAG }}