@@ -29,45 +29,54 @@ jobs:
2929 app-id : ' ${{ secrets.CR_APP_CI_APP_ID }}'
3030 private-key : ' ${{ secrets.CR_APP_CI_PRIVATE_KEY }}'
3131 owner : ' ${{ env.FLUX_OWNER }}'
32- repositories : ' ${{ env.FLUX_REPO }}'
32+ repositories : |
33+ '${{ env.FLUX_REPO }}'
34+ gitingest
35+
3336 - name : Checkout Flux repo
3437 uses : actions/checkout@v4
3538 with :
3639 repository : ' ${{ env.FLUX_OWNER }}/${{ env.FLUX_REPO }}'
3740 token : ' ${{ steps.app-token.outputs.token }}'
3841 path : flux-repo
3942 persist-credentials : false
43+
4044 - name : Export PR ID
41- run : ' echo "PR_ID=${{ github.event.pull_request.number }}" >> $GITHUB_ENV'
4245 shell : bash
46+ run : ' echo "PR_ID=${{ github.event.pull_request.number }}" >> $GITHUB_ENV'
47+
4348 - name : Ensure template exists
49+ shell : bash
4450 run : >
4551 T="flux-repo/pr-template/${APP_NAME}"
4652
4753 [[ -d "$T" ]] || { echo "Missing $T"; exit 1; }
4854
4955 [[ $(find "$T" -type f | wc -l) -gt 0 ]] || { echo "No files in $T";
5056 exit 1; }
51- shell : bash
57+
5258 - name : Render & copy template
59+ shell : bash
5360 run : |
5461 SRC="flux-repo/pr-template/${APP_NAME}"
5562 DST="flux-repo/deployments/prs-${APP_NAME}/${PR_ID}"
5663 mkdir -p "$DST"
5764 cp -r "$SRC/." "$DST/"
5865 find "$DST" -type f -print0 \
5966 | xargs -0 -n1 sed -i "s|@PR-ID@|${PR_ID}|g"
60- shell : bash
67+
6168 - name : Sanity‑check rendered output
69+ shell : bash
6270 run : >
6371 E=$(find "flux-repo/pr-template/${APP_NAME}" -type f | wc -l)
6472
6573 G=$(find "flux-repo/deployments/prs-${APP_NAME}/${PR_ID}" -type f | wc
6674 -l)
6775
6876 (( G == E )) || { echo "Expected $E files, got $G"; exit 1; }
69- shell : bash
77+
7078 - name : Commit & push creation
79+ shell : bash
7180 run : >
7281 cd flux-repo
7382
@@ -84,13 +93,22 @@ jobs:
8493 git remote set-url origin \
8594 https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/${{ env.FLUX_OWNER }}/${{ env.FLUX_REPO }}.git
8695 git push origin HEAD:main
87- shell : bash
96+
97+ - name : Comment preview URL on PR
98+ uses : thollander/actions-comment-pull-request@v3
99+ with :
100+ github-token : ' ${{ steps.app-token.outputs.token }}'
101+ pr-number : ' ${{ github.event.pull_request.number }}'
102+ comment-tag : ' pr-preview'
103+ create-if-not-exists : ' true'
104+ message : |
105+ ⚙️ Preview environment for PR #${{ env.PR_ID }} is available at:
106+ https://pr-${{ env.PR_ID }}.${{ env.APP_NAME }}.coderamp.dev/
88107
89108 remove-pr-env :
90109 if : >-
91110 (github.event.action == 'unlabeled' && github.event.label.name ==
92- 'deploy-pr-temp-env') || (github.event.action == 'closed' &&
93- github.event.pull_request.merged == true)
111+ 'deploy-pr-temp-env') || (github.event.action == 'closed')
94112 runs-on : ubuntu-latest
95113 steps :
96114 - name : Create GitHub App token
@@ -100,18 +118,24 @@ jobs:
100118 app-id : ' ${{ secrets.CR_APP_CI_APP_ID }}'
101119 private-key : ' ${{ secrets.CR_APP_CI_PRIVATE_KEY }}'
102120 owner : ' ${{ env.FLUX_OWNER }}'
103- repositories : ' ${{ env.FLUX_REPO }}'
121+ repositories : |
122+ '${{ env.FLUX_REPO }}'
123+ gitingest
124+
104125 - name : Checkout Flux repo
105126 uses : actions/checkout@v4
106127 with :
107128 repository : ' ${{ env.FLUX_OWNER }}/${{ env.FLUX_REPO }}'
108129 token : ' ${{ steps.app-token.outputs.token }}'
109130 path : flux-repo
110131 persist-credentials : false
132+
111133 - name : Export PR ID
112- run : ' echo "PR_ID=${{ github.event.pull_request.number }}" >> $GITHUB_ENV'
113134 shell : bash
135+ run : ' echo "PR_ID=${{ github.event.pull_request.number }}" >> $GITHUB_ENV'
136+
114137 - name : Remove deployed directory
138+ shell : bash
115139 run : |
116140 DST="flux-repo/deployments/prs-${APP_NAME}/${PR_ID}"
117141 if [[ -d "$DST" ]]; then
@@ -120,8 +144,9 @@ jobs:
120144 else
121145 echo "⏭️ Nothing to delete at $DST"
122146 fi
123- shell : bash
147+
124148 - name : Commit & push deletion
149+ shell : bash
125150 run : >
126151 cd flux-repo
127152
@@ -138,4 +163,13 @@ jobs:
138163 git remote set-url origin \
139164 https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/${{ env.FLUX_OWNER }}/${{ env.FLUX_REPO }}.git
140165 git push origin HEAD:main
141- shell : bash
166+
167+ - name : Comment preview URL on PR
168+ uses : thollander/actions-comment-pull-request@v3
169+ with :
170+ github-token : ' ${{ steps.app-token.outputs.token }}'
171+ pr-number : ' ${{ github.event.pull_request.number }}'
172+ comment-tag : ' pr-preview'
173+ create-if-not-exists : ' true'
174+ message : |
175+ ⚙️ Preview environment was undeployed.
0 commit comments