Skip to content

Commit 5979804

Browse files
authored
Get Review Apps working (#583)
1 parent 3690cc6 commit 5979804

File tree

3 files changed

+100
-45
lines changed

3 files changed

+100
-45
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Control Plane GitHub Action
2+
3+
name: Deploy-To-Control-Plane
4+
description: 'Deploys both to staging and to review apps'
5+
6+
inputs:
7+
# The name of the app to deploy
8+
app_name:
9+
description: 'The name of the app to deploy'
10+
required: true
11+
default:
12+
org:
13+
description: 'The org of the app to deploy'
14+
required: true
15+
default:
16+
17+
runs:
18+
using: 'composite'
19+
steps:
20+
- name: Set up Ruby
21+
uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: '3.2' # Specify your Ruby version here
24+
25+
- name: Install Control Plane CLI
26+
shell: bash
27+
run: |
28+
sudo npm install -g @controlplane/cli
29+
cpln --version
30+
gem install cpl -v 1.2.0
31+
32+
- name: Set Short SHA
33+
id: vars
34+
shell: bash
35+
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
36+
37+
- name: cpl profile
38+
shell: bash
39+
run: |
40+
cpln profile update default
41+
# cpln profile update default --token ${CPLN_TOKEN}
42+
43+
# Caching step
44+
- uses: actions/cache@v2
45+
with:
46+
path: /tmp/.docker-cache
47+
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }}-${{ github.sha }}
48+
restore-keys: |
49+
${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }}
50+
${{ runner.os }}-docker-
51+
52+
- name: cpl build-image
53+
shell: bash
54+
run: |
55+
cpln image docker-login
56+
cpl build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{inputs.org}}
57+
# --cache /tmp/.docker-cache
58+
59+
- name: Run release script
60+
shell: bash
61+
run: |
62+
# Run database migrations (or other release tasks) with the latest image,
63+
# while the app is still running on the previous image.
64+
# This is analogous to the release phase.
65+
cpl run:detached './.controlplane/release_script.sh' -a ${{ inputs.app_name }} --image latest
66+
67+
- name: Deploy to Control Plane
68+
shell: bash
69+
run: |
70+
cpl deploy-image -a ${{ inputs.app_name }} --org ${{inputs.org}}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Control Plane GitHub Action
2+
3+
name: Deploy-To-Control-Plane-Staging
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
# Convert the GitHub secret variables to environment variables for use by the Control Plane CLI
11+
env:
12+
CPLN_ORG: ${{secrets.CPLN_ORG_STAGING}}
13+
CPLN_TOKEN: ${{secrets.CPLN_TOKEN_STAGING}}
14+
15+
jobs:
16+
deploy-to-control-plane-staging:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Check out the repo
21+
uses: actions/checkout@v2
22+
23+
- uses: ./.github/actions/deploy-to-control-plane
24+
with:
25+
app_name: qa-react-webpack-rails-tutorial-pr-${{ github.event.pull_request.number }}
26+
org: ${{ secrets.CPLN_ORG_STAGING }}
Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Control Plane GitHub Action
22

3-
name: Deploy-To-Control-Plane
3+
name: Deploy-To-Control-Plane-Staging
44

55
# Controls when the workflow will run
66
on:
@@ -24,48 +24,7 @@ jobs:
2424
- name: Check out the repo
2525
uses: actions/checkout@v2
2626

27-
- name: Set up Ruby
28-
uses: ruby/setup-ruby@v1
27+
- uses: ./.github/actions/deploy-to-control-plane
2928
with:
30-
ruby-version: '3.2' # Specify your Ruby version here
31-
32-
- name: Install Control Plane CLI
33-
shell: bash
34-
run: |
35-
sudo npm install -g @controlplane/cli
36-
cpln --version
37-
gem install cpl -v 1.2.0
38-
39-
- name: Set Short SHA
40-
id: vars
41-
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
42-
43-
- name: cpl profile
44-
run: |
45-
cpln profile update default
46-
# cpln profile update default --token ${CPLN_TOKEN}
47-
48-
# Caching step
49-
- uses: actions/cache@v2
50-
with:
51-
path: /tmp/.docker-cache
52-
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }}-${{ github.sha }}
53-
restore-keys: |
54-
${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }}
55-
${{ runner.os }}-docker-
56-
57-
- name: cpl build-image
58-
run: |
59-
cpln image docker-login
60-
cpl build-image -a ${{ secrets.APP_NAME_STAGING }} --commit ${{steps.vars.outputs.sha_short}} --org ${{secrets.CPLN_ORG_STAGING}}
61-
62-
- name: Run release script
63-
run: |
64-
# Run database migrations (or other release tasks) with the latest image,
65-
# while the app is still running on the previous image.
66-
# This is analogous to the release phase.
67-
cpl run:detached './.controlplane/release_script.sh' -a ${{ secrets.APP_NAME_STAGING }} --image latest
68-
69-
- name: Deploy to Control Plane
70-
run: |
71-
cpl deploy-image -a ${{ secrets.APP_NAME_STAGING }} --org ${{secrets.CPLN_ORG_STAGING}}
29+
app_name: ${{ secrets.APP_NAME_STAGING }}
30+
org: ${{ secrets.CPLN_ORG_STAGING }}

0 commit comments

Comments
 (0)