From adfd03cdda086ed0207bb3201ec372d4adcf18f1 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 9 Jan 2024 22:21:34 -1000 Subject: [PATCH 01/14] WIP --- .github/actions/deploy-to-control-plane.yml | 65 +++++++++++++++++++ .../deploy-to-control-plane-staging.yml | 52 ++------------- 2 files changed, 69 insertions(+), 48 deletions(-) create mode 100644 .github/actions/deploy-to-control-plane.yml diff --git a/.github/actions/deploy-to-control-plane.yml b/.github/actions/deploy-to-control-plane.yml new file mode 100644 index 00000000..5e61db6b --- /dev/null +++ b/.github/actions/deploy-to-control-plane.yml @@ -0,0 +1,65 @@ +# Control Plane GitHub Action + +name: Deploy-To-Control-Plane +description: Deploys both to staging and to review apps + +inputs: + # The name of the app to deploy + app_name: + description: 'The name of the app to deploy' + required: true + default: 'react-webpack-rails-tutorial' + +env: + CPLN_ORG: ${{secrets.CPLN_ORG_STAGING}} + CPLN_TOKEN: ${{secrets.CPLN_TOKEN_STAGING}} + +runs: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' # Specify your Ruby version here + + - name: Install Control Plane CLI + shell: bash + run: | + sudo npm install -g @controlplane/cli + cpln --version + gem install cpl -v 1.2.0 + + - name: Set Short SHA + id: vars + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + + - name: cpl profile + run: | + cpln profile update default +# cpln profile update default --token ${CPLN_TOKEN} + + # Caching step + - uses: actions/cache@v2 + with: + path: /tmp/.docker-cache + key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }} + ${{ runner.os }}-docker- + + - name: cpl build-image + run: | + cpln image docker-login + cpl build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{secrets.CPLN_ORG_STAGING}} + + - name: Run release script + run: | + # Run database migrations (or other release tasks) with the latest image, + # while the app is still running on the previous image. + # This is analogous to the release phase. + cpl run:detached './.controlplane/release_script.sh' -a ${{ inputs.app_name }} --image latest + + - name: Deploy to Control Plane + run: | + cpl deploy-image -a ${{ inputs.app_name }} --org ${{secrets.CPLN_ORG_STAGING}} diff --git a/.github/workflows/deploy-to-control-plane-staging.yml b/.github/workflows/deploy-to-control-plane-staging.yml index 393c9a5c..88b42d44 100644 --- a/.github/workflows/deploy-to-control-plane-staging.yml +++ b/.github/workflows/deploy-to-control-plane-staging.yml @@ -1,6 +1,7 @@ # Control Plane GitHub Action -name: Deploy-To-Control-Plane +name: Deploy-To-Control-Plane-Staging +description: Deploys to staging # Controls when the workflow will run on: @@ -21,51 +22,6 @@ jobs: runs-on: ubuntu-latest steps: - - name: Check out the repo - uses: actions/checkout@v2 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 + - uses: ./.github/actions/deploy-to-control-plane.yml with: - ruby-version: '3.2' # Specify your Ruby version here - - - name: Install Control Plane CLI - shell: bash - run: | - sudo npm install -g @controlplane/cli - cpln --version - gem install cpl -v 1.2.0 - - - name: Set Short SHA - id: vars - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - - name: cpl profile - run: | - cpln profile update default -# cpln profile update default --token ${CPLN_TOKEN} - - # Caching step - - uses: actions/cache@v2 - with: - path: /tmp/.docker-cache - key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }} - ${{ runner.os }}-docker- - - - name: cpl build-image - run: | - cpln image docker-login - cpl build-image -a ${{ secrets.APP_NAME_STAGING }} --commit ${{steps.vars.outputs.sha_short}} --org ${{secrets.CPLN_ORG_STAGING}} - - - name: Run release script - run: | - # Run database migrations (or other release tasks) with the latest image, - # while the app is still running on the previous image. - # This is analogous to the release phase. - cpl run:detached './.controlplane/release_script.sh' -a ${{ secrets.APP_NAME_STAGING }} --image latest - - - name: Deploy to Control Plane - run: | - cpl deploy-image -a ${{ secrets.APP_NAME_STAGING }} --org ${{secrets.CPLN_ORG_STAGING}} + app_name: secrets.APP_NAME_STAGING From 68d31b46947e166aaadebf295e804f4711cbe8c2 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 9 Jan 2024 22:22:59 -1000 Subject: [PATCH 02/14] WIP --- .github/workflows/deploy-to-control-plane-staging.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy-to-control-plane-staging.yml b/.github/workflows/deploy-to-control-plane-staging.yml index 88b42d44..f75de0b8 100644 --- a/.github/workflows/deploy-to-control-plane-staging.yml +++ b/.github/workflows/deploy-to-control-plane-staging.yml @@ -1,7 +1,6 @@ # Control Plane GitHub Action name: Deploy-To-Control-Plane-Staging -description: Deploys to staging # Controls when the workflow will run on: From a334d33d1280102c6b91b405109fbb624a8a43fc Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 9 Jan 2024 22:25:29 -1000 Subject: [PATCH 03/14] WIP --- .github/actions/deploy-to-control-plane.yml | 3 --- .github/workflows/deploy-to-control-plane-staging.yml | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/deploy-to-control-plane.yml b/.github/actions/deploy-to-control-plane.yml index 5e61db6b..c23be7f2 100644 --- a/.github/actions/deploy-to-control-plane.yml +++ b/.github/actions/deploy-to-control-plane.yml @@ -15,9 +15,6 @@ env: CPLN_TOKEN: ${{secrets.CPLN_TOKEN_STAGING}} runs: - - name: Check out the repo - uses: actions/checkout@v2 - - name: Set up Ruby uses: ruby/setup-ruby@v1 with: diff --git a/.github/workflows/deploy-to-control-plane-staging.yml b/.github/workflows/deploy-to-control-plane-staging.yml index f75de0b8..4bd2c9a7 100644 --- a/.github/workflows/deploy-to-control-plane-staging.yml +++ b/.github/workflows/deploy-to-control-plane-staging.yml @@ -21,6 +21,9 @@ jobs: runs-on: ubuntu-latest steps: + - name: Check out the repo + uses: actions/checkout@v2 + - uses: ./.github/actions/deploy-to-control-plane.yml with: app_name: secrets.APP_NAME_STAGING From 075bd99abade3262a441ab06440cfbe50501e6aa Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 9 Jan 2024 22:27:53 -1000 Subject: [PATCH 04/14] WIP --- .github/actions/deploy-to-control-plane.yml | 2 +- .github/workflows/deploy-to-control-plane-staging.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/deploy-to-control-plane.yml b/.github/actions/deploy-to-control-plane.yml index c23be7f2..52d25568 100644 --- a/.github/actions/deploy-to-control-plane.yml +++ b/.github/actions/deploy-to-control-plane.yml @@ -1,7 +1,7 @@ # Control Plane GitHub Action name: Deploy-To-Control-Plane -description: Deploys both to staging and to review apps +description: 'Deploys both to staging and to review apps' inputs: # The name of the app to deploy diff --git a/.github/workflows/deploy-to-control-plane-staging.yml b/.github/workflows/deploy-to-control-plane-staging.yml index 4bd2c9a7..9bc149c9 100644 --- a/.github/workflows/deploy-to-control-plane-staging.yml +++ b/.github/workflows/deploy-to-control-plane-staging.yml @@ -24,6 +24,6 @@ jobs: - name: Check out the repo uses: actions/checkout@v2 - - uses: ./.github/actions/deploy-to-control-plane.yml + - uses: ../actions/deploy-to-control-plane.yml with: app_name: secrets.APP_NAME_STAGING From a81f8a51a601fe244c291d98878cd058696a9b06 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 9 Jan 2024 22:30:16 -1000 Subject: [PATCH 05/14] WIP --- .github/workflows/deploy-to-control-plane-staging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-to-control-plane-staging.yml b/.github/workflows/deploy-to-control-plane-staging.yml index 9bc149c9..4bd2c9a7 100644 --- a/.github/workflows/deploy-to-control-plane-staging.yml +++ b/.github/workflows/deploy-to-control-plane-staging.yml @@ -24,6 +24,6 @@ jobs: - name: Check out the repo uses: actions/checkout@v2 - - uses: ../actions/deploy-to-control-plane.yml + - uses: ./.github/actions/deploy-to-control-plane.yml with: app_name: secrets.APP_NAME_STAGING From 2931e1d390abee57ca4222a08428d1e9b99fb978 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 9 Jan 2024 22:33:19 -1000 Subject: [PATCH 06/14] WIP --- .../action.yml} | 0 .github/workflows/deploy-to-control-plane-staging.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/actions/{deploy-to-control-plane.yml => deploy-to-control-plane/action.yml} (100%) diff --git a/.github/actions/deploy-to-control-plane.yml b/.github/actions/deploy-to-control-plane/action.yml similarity index 100% rename from .github/actions/deploy-to-control-plane.yml rename to .github/actions/deploy-to-control-plane/action.yml diff --git a/.github/workflows/deploy-to-control-plane-staging.yml b/.github/workflows/deploy-to-control-plane-staging.yml index 4bd2c9a7..fc444163 100644 --- a/.github/workflows/deploy-to-control-plane-staging.yml +++ b/.github/workflows/deploy-to-control-plane-staging.yml @@ -24,6 +24,6 @@ jobs: - name: Check out the repo uses: actions/checkout@v2 - - uses: ./.github/actions/deploy-to-control-plane.yml + - uses: ./.github/actions/deploy-to-control-plane with: app_name: secrets.APP_NAME_STAGING From 211bc139c76981b143428263d036fdb6949b80e4 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 9 Jan 2024 22:35:05 -1000 Subject: [PATCH 07/14] WIP --- .github/actions/deploy-to-control-plane/action.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/actions/deploy-to-control-plane/action.yml b/.github/actions/deploy-to-control-plane/action.yml index 52d25568..6464b619 100644 --- a/.github/actions/deploy-to-control-plane/action.yml +++ b/.github/actions/deploy-to-control-plane/action.yml @@ -10,10 +10,6 @@ inputs: required: true default: 'react-webpack-rails-tutorial' -env: - CPLN_ORG: ${{secrets.CPLN_ORG_STAGING}} - CPLN_TOKEN: ${{secrets.CPLN_TOKEN_STAGING}} - runs: - name: Set up Ruby uses: ruby/setup-ruby@v1 From 94143e1abde8eb0eb07303939ed87003b9852ca9 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 9 Jan 2024 22:37:14 -1000 Subject: [PATCH 08/14] WIP --- .../deploy-to-control-plane/action.yml | 88 ++++++++++--------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/.github/actions/deploy-to-control-plane/action.yml b/.github/actions/deploy-to-control-plane/action.yml index 6464b619..e375c12e 100644 --- a/.github/actions/deploy-to-control-plane/action.yml +++ b/.github/actions/deploy-to-control-plane/action.yml @@ -11,48 +11,50 @@ inputs: default: 'react-webpack-rails-tutorial' runs: - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.2' # Specify your Ruby version here - - - name: Install Control Plane CLI - shell: bash - run: | - sudo npm install -g @controlplane/cli - cpln --version - gem install cpl -v 1.2.0 - - - name: Set Short SHA - id: vars - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - - name: cpl profile - run: | - cpln profile update default -# cpln profile update default --token ${CPLN_TOKEN} - - # Caching step - - uses: actions/cache@v2 - with: - path: /tmp/.docker-cache - key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }} - ${{ runner.os }}-docker- - - - name: cpl build-image - run: | - cpln image docker-login - cpl build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{secrets.CPLN_ORG_STAGING}} - - - name: Run release script - run: | - # Run database migrations (or other release tasks) with the latest image, - # while the app is still running on the previous image. - # This is analogous to the release phase. - cpl run:detached './.controlplane/release_script.sh' -a ${{ inputs.app_name }} --image latest - - - name: Deploy to Control Plane + using: 'composite' + steps: + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' # Specify your Ruby version here + + - name: Install Control Plane CLI + shell: bash + run: | + sudo npm install -g @controlplane/cli + cpln --version + gem install cpl -v 1.2.0 + + - name: Set Short SHA + id: vars + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + + - name: cpl profile + run: | + cpln profile update default + # cpln profile update default --token ${CPLN_TOKEN} + + # Caching step + - uses: actions/cache@v2 + with: + path: /tmp/.docker-cache + key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }} + ${{ runner.os }}-docker- + + - name: cpl build-image + run: | + cpln image docker-login + cpl build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{secrets .CPLN_ORG_STAGING}} + + - name: Run release script + run: | + # Run database migrations (or other release tasks) with the latest image, + # while the app is still running on the previous image. + # This is analogous to the release phase. + cpl run:detached './.controlplane/release_script.sh' -a ${{ inputs.app_name }} --image latest + + - name: Deploy to Control Plane run: | cpl deploy-image -a ${{ inputs.app_name }} --org ${{secrets.CPLN_ORG_STAGING}} From 9770b178ad0986e23d6d9ec87f976dfda395721c Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 9 Jan 2024 22:38:59 -1000 Subject: [PATCH 09/14] WIP --- .github/actions/deploy-to-control-plane/action.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/actions/deploy-to-control-plane/action.yml b/.github/actions/deploy-to-control-plane/action.yml index e375c12e..d943f488 100644 --- a/.github/actions/deploy-to-control-plane/action.yml +++ b/.github/actions/deploy-to-control-plane/action.yml @@ -27,9 +27,11 @@ runs: - name: Set Short SHA id: vars + shell: bash run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - name: cpl profile + shell: bash run: | cpln profile update default # cpln profile update default --token ${CPLN_TOKEN} @@ -44,11 +46,13 @@ runs: ${{ runner.os }}-docker- - name: cpl build-image + shell: bash run: | cpln image docker-login cpl build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{secrets .CPLN_ORG_STAGING}} - name: Run release script + shell: bash run: | # Run database migrations (or other release tasks) with the latest image, # while the app is still running on the previous image. @@ -56,5 +60,6 @@ runs: cpl run:detached './.controlplane/release_script.sh' -a ${{ inputs.app_name }} --image latest - name: Deploy to Control Plane - run: | - cpl deploy-image -a ${{ inputs.app_name }} --org ${{secrets.CPLN_ORG_STAGING}} + shell: bash + run: | + cpl deploy-image -a ${{ inputs.app_name }} --org ${{secrets.CPLN_ORG_STAGING}} From 8e2d19f967c5ae834907187aabb2668829bbbfb7 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 9 Jan 2024 22:40:52 -1000 Subject: [PATCH 10/14] WIP --- .github/actions/deploy-to-control-plane/action.yml | 8 ++++++-- .github/workflows/deploy-to-control-plane-staging.yml | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/actions/deploy-to-control-plane/action.yml b/.github/actions/deploy-to-control-plane/action.yml index d943f488..cd9b8f7a 100644 --- a/.github/actions/deploy-to-control-plane/action.yml +++ b/.github/actions/deploy-to-control-plane/action.yml @@ -8,7 +8,11 @@ inputs: app_name: description: 'The name of the app to deploy' required: true - default: 'react-webpack-rails-tutorial' + default: + org: + description: 'The org of the app to deploy' + required: true + default: runs: using: 'composite' @@ -62,4 +66,4 @@ runs: - name: Deploy to Control Plane shell: bash run: | - cpl deploy-image -a ${{ inputs.app_name }} --org ${{secrets.CPLN_ORG_STAGING}} + cpl deploy-image -a ${{ inputs.app_name }} --org ${{inputs.org}} diff --git a/.github/workflows/deploy-to-control-plane-staging.yml b/.github/workflows/deploy-to-control-plane-staging.yml index fc444163..db69924d 100644 --- a/.github/workflows/deploy-to-control-plane-staging.yml +++ b/.github/workflows/deploy-to-control-plane-staging.yml @@ -27,3 +27,4 @@ jobs: - uses: ./.github/actions/deploy-to-control-plane with: app_name: secrets.APP_NAME_STAGING + org: secrets.CPLN_ORG_STAGING From b22b9bba0acd4e7486f62437f5ccf36c6feeedb3 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 9 Jan 2024 22:41:55 -1000 Subject: [PATCH 11/14] WIP --- .github/actions/deploy-to-control-plane/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/deploy-to-control-plane/action.yml b/.github/actions/deploy-to-control-plane/action.yml index cd9b8f7a..a5e563a4 100644 --- a/.github/actions/deploy-to-control-plane/action.yml +++ b/.github/actions/deploy-to-control-plane/action.yml @@ -53,7 +53,7 @@ runs: shell: bash run: | cpln image docker-login - cpl build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{secrets .CPLN_ORG_STAGING}} + cpl build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{inputs.org}} --cache /tmp/.docker-cache - name: Run release script shell: bash From e7233ad4df429fcc94dffccfca0ef363df2daefa Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 9 Jan 2024 22:45:43 -1000 Subject: [PATCH 12/14] WIP --- .github/actions/deploy-to-control-plane/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/deploy-to-control-plane/action.yml b/.github/actions/deploy-to-control-plane/action.yml index a5e563a4..64a4336c 100644 --- a/.github/actions/deploy-to-control-plane/action.yml +++ b/.github/actions/deploy-to-control-plane/action.yml @@ -53,7 +53,8 @@ runs: shell: bash run: | cpln image docker-login - cpl build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{inputs.org}} --cache /tmp/.docker-cache + cpl build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{inputs.org}} + # --cache /tmp/.docker-cache - name: Run release script shell: bash From 76dfbe71443bba9d78544443d3dcd449e5fd25c5 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 9 Jan 2024 22:48:08 -1000 Subject: [PATCH 13/14] WIP --- .github/workflows/deploy-to-control-plane-staging.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-to-control-plane-staging.yml b/.github/workflows/deploy-to-control-plane-staging.yml index db69924d..1f276b5c 100644 --- a/.github/workflows/deploy-to-control-plane-staging.yml +++ b/.github/workflows/deploy-to-control-plane-staging.yml @@ -26,5 +26,5 @@ jobs: - uses: ./.github/actions/deploy-to-control-plane with: - app_name: secrets.APP_NAME_STAGING - org: secrets.CPLN_ORG_STAGING + app_name: ${{ secrets.APP_NAME_STAGING }} + org: ${{ secrets.CPLN_ORG_STAGING }} From be7f52f4cd91addc3ead0d7c416b2f1a1ccbb910 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Mon, 15 Jan 2024 17:24:35 -1000 Subject: [PATCH 14/14] add review app --- .../deploy-to-control-plane-review.yml | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/deploy-to-control-plane-review.yml diff --git a/.github/workflows/deploy-to-control-plane-review.yml b/.github/workflows/deploy-to-control-plane-review.yml new file mode 100644 index 00000000..439c7290 --- /dev/null +++ b/.github/workflows/deploy-to-control-plane-review.yml @@ -0,0 +1,26 @@ +# Control Plane GitHub Action + +name: Deploy-To-Control-Plane-Staging + +# Controls when the workflow will run +on: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Convert the GitHub secret variables to environment variables for use by the Control Plane CLI +env: + CPLN_ORG: ${{secrets.CPLN_ORG_STAGING}} + CPLN_TOKEN: ${{secrets.CPLN_TOKEN_STAGING}} + +jobs: + deploy-to-control-plane-staging: + runs-on: ubuntu-latest + + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - uses: ./.github/actions/deploy-to-control-plane + with: + app_name: qa-react-webpack-rails-tutorial-pr-${{ github.event.pull_request.number }} + org: ${{ secrets.CPLN_ORG_STAGING }}