Test GitHub triggering review app deployments #39
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: | |
# Triggers the workflow on pull request events | |
pull_request: | |
branches: | |
- master | |
# 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}} | |
PR_NUMBER: ${{github.event.number}} | |
jobs: | |
deploy-to-control-plane-review: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v2 | |
- name: Get PR number | |
run: | | |
echo "GITHUB_REPOSITORY: \"$GITHUB_REPOSITORY\"" | |
if [ -z "$PR_NUMBER" ]; then | |
echo "PR_NUMBER is not in the trigger event. Fetching PR number from open PRs." | |
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 }}') | |
PR_NUMBER=$(echo $API_RESPONSE | jq '.[] | select(.head.ref=="'$REF'") | .number') | |
fi | |
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 | |
- name: Get App Name | |
run: | | |
echo "PR_NUMBER: ${{ env.PR_NUMBER }}" | |
echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-${{ env.PR_NUMBER }}" >> $GITHUB_ENV | |
echo "App Name: ${{ env.APP_NAME }}" | |
- uses: ./.github/actions/deploy-to-control-plane | |
with: | |
app_name: ${{ env.APP_NAME }} | |
org: ${{ env.CPLN_ORG }} |