@@ -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
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 : >-
@@ -101,17 +120,21 @@ jobs:
101120 private-key : ' ${{ secrets.CR_APP_CI_PRIVATE_KEY }}'
102121 owner : ' ${{ env.FLUX_OWNER }}'
103122 repositories : ' ${{ env.FLUX_REPO }}'
123+
104124 - name : Checkout Flux repo
105125 uses : actions/checkout@v4
106126 with :
107127 repository : ' ${{ env.FLUX_OWNER }}/${{ env.FLUX_REPO }}'
108128 token : ' ${{ steps.app-token.outputs.token }}'
109129 path : flux-repo
110130 persist-credentials : false
131+
111132 - name : Export PR ID
112- run : ' echo "PR_ID=${{ github.event.pull_request.number }}" >> $GITHUB_ENV'
113133 shell : bash
134+ run : ' echo "PR_ID=${{ github.event.pull_request.number }}" >> $GITHUB_ENV'
135+
114136 - name : Remove deployed directory
137+ shell : bash
115138 run : |
116139 DST="flux-repo/deployments/prs-${APP_NAME}/${PR_ID}"
117140 if [[ -d "$DST" ]]; then
@@ -120,8 +143,9 @@ jobs:
120143 else
121144 echo "⏭️ Nothing to delete at $DST"
122145 fi
123- shell : bash
146+
124147 - name : Commit & push deletion
148+ shell : bash
125149 run : >
126150 cd flux-repo
127151
@@ -138,4 +162,13 @@ jobs:
138162 git remote set-url origin \
139163 https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/${{ env.FLUX_OWNER }}/${{ env.FLUX_REPO }}.git
140164 git push origin HEAD:main
141- shell : bash
165+
166+ - name : Comment preview URL on PR
167+ uses : thollander/actions-comment-pull-request@v3
168+ with :
169+ github-token : ' ${{ steps.app-token.outputs.token }}'
170+ pr-number : ' ${{ github.event.pull_request.number }}'
171+ comment-tag : ' pr-preview'
172+ create-if-not-exists : ' true'
173+ message : |
174+ ⚙️ Preview environment was undeployed.
0 commit comments