From 62417a8b86b938f3080ca0d0d051871f9ede66e5 Mon Sep 17 00:00:00 2001 From: Pavel Murygin Date: Thu, 17 Jun 2021 13:20:58 +0300 Subject: [PATCH] split deployment and build statges --- .../{deploy_prod.yml => build_prod.yml} | 26 ++++------------- .github/workflows/deploy.yml | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+), 21 deletions(-) rename .github/workflows/{deploy_prod.yml => build_prod.yml} (63%) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/build_prod.yml similarity index 63% rename from .github/workflows/deploy_prod.yml rename to .github/workflows/build_prod.yml index d440394..2eb0db2 100644 --- a/.github/workflows/deploy_prod.yml +++ b/.github/workflows/build_prod.yml @@ -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 }} \ No newline at end of file + workflow: Some Workflow + token: ${{ secrets.PERSONAL_TOKEN }} + inputs: '{ "version": ${{ env.VERSION }} }' diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..275935d --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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 }}