@@ -6,21 +6,27 @@ 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
9
13
# inputs:
10
14
# pr_number:
11
15
# description: 'Pull request number'
12
16
# 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
17
17
issue_comment :
18
18
types : [created, edited]
19
19
20
+ # Triggers the workflow on pull request events
21
+ pull_request :
22
+ branches :
23
+ - master
24
+
20
25
# Convert the GitHub secret variables to environment variables for use by the Control Plane CLI
21
26
env :
22
27
CPLN_ORG : ${{secrets.CPLN_ORG_STAGING}}
23
28
CPLN_TOKEN : ${{secrets.CPLN_TOKEN_STAGING}}
29
+ PR_NUMBER : ${{github.event.number}}
24
30
25
31
jobs :
26
32
deploy-to-control-plane-review :
@@ -34,13 +40,15 @@ jobs:
34
40
- name : Get PR number
35
41
run : |
36
42
echo "GITHUB_REPOSITORY: \"$GITHUB_REPOSITORY\""
37
- REF=${{ github.ref }}
38
- REF=${REF#refs/heads/} # Remove 'refs/heads/' prefix
39
- echo "REF: \"$REF\""
40
- API_RESPONSE=$(curl --location --request GET "https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open" \
41
- --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}')
42
- echo "API_RESPONSE: $API_RESPONSE"
43
- PR_NUMBER=$(echo $API_RESPONSE | jq '.[] | select(.head.ref=="'$REF'") | .number')
43
+ if [ -z "$PR_NUMBER" ]; then
44
+ echo "PR_NUMBER is not in the trigger event. Fetching PR number from open PRs."
45
+ REF=${{ github.ref }}
46
+ REF=${REF#refs/heads/} # Remove 'refs/heads/' prefix
47
+ echo "REF: \"$REF\""
48
+ API_RESPONSE=$(curl --location --request GET "https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open" \
49
+ --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}')
50
+ PR_NUMBER=$(echo $API_RESPONSE | jq '.[] | select(.head.ref=="'$REF'") | .number')
51
+ fi
44
52
echo "PR_NUMBER: $PR_NUMBER"
45
53
if [ -z "$PR_NUMBER" ]; then
46
54
echo "PR_NUMBER is not set. Aborting."
57
65
- uses : ./.github/actions/deploy-to-control-plane
58
66
with :
59
67
app_name : ${{ env.APP_NAME }}
60
- org : ${{ secrets.CPLN_ORG_STAGING }}
68
+ org : ${{ env.CPLN_ORG }}
0 commit comments