Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
justin808 committed Jan 10, 2024
1 parent 3690cc6 commit adfd03c
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 48 deletions.
65 changes: 65 additions & 0 deletions .github/actions/deploy-to-control-plane.yml
Original file line number Diff line number Diff line change
@@ -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}}
52 changes: 4 additions & 48 deletions .github/workflows/deploy-to-control-plane-staging.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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

0 comments on commit adfd03c

Please sign in to comment.