From 586c428917fef0089b3b547355c70321511fe8d4 Mon Sep 17 00:00:00 2001 From: Jafner <40403594+Jafner@users.noreply.github.com> Date: Thu, 30 Sep 2021 11:35:47 -0700 Subject: [PATCH] Merge CI and CD workflows --- 5etools-docker/.github/workflows/cd.yml | 46 ------------------- .../.github/workflows/{ci.yml => ci_cd.yml} | 35 ++++++++++---- 2 files changed, 27 insertions(+), 54 deletions(-) delete mode 100644 5etools-docker/.github/workflows/cd.yml rename 5etools-docker/.github/workflows/{ci.yml => ci_cd.yml} (65%) diff --git a/5etools-docker/.github/workflows/cd.yml b/5etools-docker/.github/workflows/cd.yml deleted file mode 100644 index 8ff002cc..00000000 --- a/5etools-docker/.github/workflows/cd.yml +++ /dev/null @@ -1,46 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: CD - -# Controls when the workflow will run -on: - # Triggers the workflow on push or pull request events but only for the main branch - #push: - # branches: [ main ] - # paths-ignore: # don't run this workflow if no changes have been made to the docker image - # - '.github/**' - # - 'docker-compose.yml' - #pull_request: - # branches: [ main ] - # paths-ignore: # don't run this workflow if no changes have been made to the docker image - # - '.github/**' - # - 'docker-compose.yml' - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - deploy: - name: Deploy to server - runs-on: ubuntu-latest - steps: - - name: Updating and restarting service on host via SSH - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.SITE_HOST }} - username: ${{ secrets.SITE_USERNAME }} - key: ${{ secrets.SITE_KEY }} - port: ${{ secrets.SITE_PORT }} - script: | - cd /root - docker pull jafner/5etools-docker:latest - docker-compose down - docker-compose up -d - - - name: Sending Discord notification - env: - DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} - uses: Ilshidur/action-discord@master - with: - args: 'The project {{ EVENT_PAYLOAD.repository.full_name }} has been deployed to ${{ secrets.SITE_HOST }}. Triggered by ${{ EVENT_PAYLOAD.sender }} with ${{ EVENT_PAYLOAD.action }}' \ No newline at end of file diff --git a/5etools-docker/.github/workflows/ci.yml b/5etools-docker/.github/workflows/ci_cd.yml similarity index 65% rename from 5etools-docker/.github/workflows/ci.yml rename to 5etools-docker/.github/workflows/ci_cd.yml index 59e0b62a..3d18282c 100644 --- a/5etools-docker/.github/workflows/ci.yml +++ b/5etools-docker/.github/workflows/ci_cd.yml @@ -1,10 +1,7 @@ -# This is a basic workflow to help you get started with Actions +name: CI/CD -name: CI - -# Controls when the workflow will run on: - # Triggers the workflow on push or pull request events but only for the main branch + # Triggers the workflow when changes are made to the image on the main branch push: branches: [ main ] paths-ignore: # don't run this workflow if no changes have been made to the docker image @@ -17,13 +14,11 @@ on: - '.github/**' - 'docker-compose.yml' - 'README.md' - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - push_to_registry: + ci: name: Build and push Docker image to Docker Hub runs-on: ubuntu-latest steps: @@ -68,3 +63,27 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} repository: jafner/5etools-docker + cd: + if: ${{ false }} # disable for now + name: Deploy new image to server + runs-on: ubuntu-latest + steps: + - name: Updating and restarting service on host via SSH + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SITE_HOST }} + username: ${{ secrets.SITE_USERNAME }} + key: ${{ secrets.SITE_KEY }} + port: ${{ secrets.SITE_PORT }} + script: | + cd /root + docker pull jafner/5etools-docker:latest + docker-compose down + docker-compose up -d + + - name: Sending Discord notification + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + uses: Ilshidur/action-discord@master + with: + args: 'The project {{ EVENT_PAYLOAD.repository.full_name }} has been deployed to ${{ secrets.SITE_HOST }}. Triggered by ${{ EVENT_PAYLOAD.sender }} with ${{ EVENT_PAYLOAD.action }}' \ No newline at end of file