From a6c1e2cb38b9efdf0fee1f448f3c9d8c3274ab0d Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Sat, 29 Oct 2022 19:19:04 -0700 Subject: [PATCH] Update CI for Dokku --- .github/workflows/ci.yml | 41 ++++++++++++++++++++++++++++++++++++++++ bin/ci-pre-deploy | 6 ++++++ 2 files changed, 47 insertions(+) create mode 100644 bin/ci-pre-deploy diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce86061a..f5bdec10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,6 @@ name: CI +env: + DOKKU_GIT_REMOTE_URL: 'ssh://dokku@dokku.baby-buddy.net:22/demo' on: push: branches: @@ -36,6 +38,32 @@ jobs: with: github-token: ${{ secrets.github_token }} parallel-finished: true + deploy-review-app: + needs: test + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' && github.event.action == 'opened' + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Push to dokku + uses: dokku/github-action@master + with: + command: review-apps:create + git_remote_url: ${{ env.DOKKU_GIT_REMOTE_URL }} + review_app_name: pr-${{ github.event.pull_request.number }} + ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} + destroy-review-app: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' && github.event.action == 'closed' + steps: + - name: Destroy the review app + uses: dokku/github-action@master + with: + command: review-apps:destroy + git_remote_url: ${{ env.DOKKU_GIT_REMOTE_URL }} + review_app_name: pr-${{ github.event.pull_request.number }} + ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} deploy-docs: needs: test runs-on: ubuntu-latest @@ -50,3 +78,16 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.github_token }} REQUIREMENTS: docs/requirements.txt + deploy-demo: + needs: test + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Push to dokku + uses: dokku/github-action@master + with: + git_remote_url: ${{ env.DOKKU_GIT_REMOTE_URL }} + ssh_private_key: ${{ secrets.DOKKU_SSH_PRIVATE_KEY }} diff --git a/bin/ci-pre-deploy b/bin/ci-pre-deploy new file mode 100644 index 00000000..6a365924 --- /dev/null +++ b/bin/ci-pre-deploy @@ -0,0 +1,6 @@ +#!/bin/sh -l + +if [ "$IS_REVIEW_APP" = "true" ]; then + ssh "$SSH_REMOTE" -- config:set "$APP_NAME" "DOMAIN=$APP_NAME.dokku.baby-buddy.net" + echo "configured the review app domain" +fi \ No newline at end of file