Skip to content

Deploy Review App to Control Plane #13

Deploy Review App to Control Plane

Deploy Review App to Control Plane #13

# Control Plane GitHub Action
name: Deploy Review App to Control Plane
# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# inputs:
# pr_number:
# description: 'Pull request number'
# required: false
# Triggers the workflow on pull request events
# pull_request:
# branches:
# - main # or the branch you want to trigger the workflow
# 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
- name: Get PR number
run: |
echo "GITHUB_REPOSITORY: \"$GITHUB_REPOSITORY\""
REF=${{ github.ref }}
REF=${REF#refs/heads/} # Remove 'refs/heads/' prefix
echo "REF: \"$REF\""
API_RESPONSE=$(curl --location --request GET "https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open" \
--header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}')
echo "API_RESPONSE: $API_RESPONSE"
PR_NUMBER=$(echo $API_RESPONSE | jq '.[] | select(.head.ref=="'$REF'") | .number')
echo "PR_NUMBER: $PR_NUMBER"
if [ -z "$PR_NUMBER" ]; then
echo "PR_NUMBER is not set. Aborting."
exit 1
fi
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
- uses: ./.github/actions/deploy-to-control-plane
with:
app_name: qa-react-webpack-rails-tutorial-pr-${{ env.PR_NUMBER }}
org: ${{ secrets.CPLN_ORG_STAGING }}