@@ -6,19 +6,21 @@ name: Deploy Review App to Control Plane
6
6
on :
7
7
# Allows you to run this workflow manually from the Actions tab
8
8
workflow_dispatch :
9
- # inputs:
10
- # pr_number:
11
- # description: 'Pull request number'
12
- # required: false
13
- # Triggers the workflow on pull request events
14
- # pull_request:
15
- # branches:
16
- # - main # or the branch you want to trigger the workflow
9
+ # inputs:
10
+ # pr_number:
11
+ # description: 'Pull request number'
12
+ # required: false
13
+
14
+ # Triggers the workflow on pull request events
15
+ pull_request :
16
+ branches :
17
+ - master
17
18
18
19
# Convert the GitHub secret variables to environment variables for use by the Control Plane CLI
19
20
env :
20
21
CPLN_ORG : ${{secrets.CPLN_ORG_STAGING}}
21
22
CPLN_TOKEN : ${{secrets.CPLN_TOKEN_STAGING}}
23
+ PR_NUMBER : ${{github.event.number}}
22
24
23
25
jobs :
24
26
deploy-to-control-plane-review :
@@ -31,13 +33,15 @@ jobs:
31
33
- name : Get PR number
32
34
run : |
33
35
echo "GITHUB_REPOSITORY: \"$GITHUB_REPOSITORY\""
34
- REF=${{ github.ref }}
35
- REF=${REF#refs/heads/} # Remove 'refs/heads/' prefix
36
- echo "REF: \"$REF\""
37
- API_RESPONSE=$(curl --location --request GET "https://github.com/api/repos/$GITHUB_REPOSITORY/pulls?state=open" \
38
- --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}')
39
- echo "API_RESPONSE: $API_RESPONSE"
40
- PR_NUMBER=$(echo $API_RESPONSE | jq '.[] | select(.head.ref=="'$REF'") | .number')
36
+ if [ -z "$PR_NUMBER" ]; then
37
+ echo "PR_NUMBER is not in the trigger event. Fetching PR number from open PRs."
38
+ REF=${{ github.ref }}
39
+ REF=${REF#refs/heads/} # Remove 'refs/heads/' prefix
40
+ echo "REF: \"$REF\""
41
+ API_RESPONSE=$(curl --location --request GET "https://github.com/api/repos/$GITHUB_REPOSITORY/pulls?state=open" \
42
+ --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}')
43
+ PR_NUMBER=$(echo $API_RESPONSE | jq '.[] | select(.head.ref=="'$REF'") | .number')
44
+ fi
41
45
echo "PR_NUMBER: $PR_NUMBER"
42
46
if [ -z "$PR_NUMBER" ]; then
43
47
echo "PR_NUMBER is not set. Aborting."
54
58
- uses : ./.github/actions/deploy-to-control-plane
55
59
with :
56
60
app_name : ${{ env.APP_NAME }}
57
- org : ${{ secrets.CPLN_ORG_STAGING }}
61
+ org : ${{ env.CPLN_ORG }}
0 commit comments