|
22 | 22 | id: pr |
23 | 23 | run: echo "number=$(cat pr_number.txt)" >> $GITHUB_OUTPUT |
24 | 24 |
|
| 25 | + - name: 📝 Create .htaccess for SPA routing |
| 26 | + env: |
| 27 | + PULL_NUMBER: ${{ steps.pr.outputs.number }} |
| 28 | + run: | |
| 29 | + cat > ./build/.htaccess << 'EOF' |
| 30 | + <IfModule mod_rewrite.c> |
| 31 | + RewriteEngine On |
| 32 | + RewriteBase /${PULL_NUMBER}/ |
| 33 | +
|
| 34 | + RewriteCond %{REQUEST_FILENAME} !-f |
| 35 | + RewriteCond %{REQUEST_FILENAME} !-d |
| 36 | + RewriteRule ^ index.html [L] |
| 37 | + </IfModule> |
| 38 | + EOF |
| 39 | +
|
25 | 40 | - name: 🚀 Deploy preview |
26 | 41 | env: |
27 | 42 | PULL_NUMBER: ${{ steps.pr.outputs.number }} |
|
30 | 45 | ssh-add - <<< "${{ secrets.PREVIEW_SSH_PRIVATE_KEY }}" |
31 | 46 | rsync -r --delete --rsync-path="mkdir -p ${{ vars.PREVIEW_HOST_TARGET_DIR }}/$PULL_NUMBER && rsync" -e "ssh -o StrictHostKeyChecking=no" ./build/ ${{ vars.PREVIEW_HOST_USERNAME }}@${{ vars.PREVIEW_HOST_IP }}:${{ vars.PREVIEW_HOST_TARGET_DIR }}/$PULL_NUMBER |
32 | 47 |
|
| 48 | + - name: ✅ Update PR status check |
| 49 | + uses: actions/github-script@v7 |
| 50 | + with: |
| 51 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + script: | |
| 53 | + const prNumber = parseInt('${{ steps.pr.outputs.number }}'); |
| 54 | + const { data: pr } = await github.rest.pulls.get({ |
| 55 | + owner: context.repo.owner, |
| 56 | + repo: context.repo.repo, |
| 57 | + pull_number: prNumber |
| 58 | + }); |
| 59 | + await github.rest.repos.createCommitStatus({ |
| 60 | + owner: context.repo.owner, |
| 61 | + repo: context.repo.repo, |
| 62 | + sha: pr.head.sha, |
| 63 | + state: 'success', |
| 64 | + target_url: `https://valhalla-app-tests.gis-ops.com/${prNumber}`, |
| 65 | + description: 'Preview deployed successfully', |
| 66 | + context: 'PR Preview Deploy' |
| 67 | + }); |
| 68 | +
|
33 | 69 | - name: 🌐 Comment preview URL |
34 | 70 | uses: actions/github-script@v7 |
35 | 71 | with: |
|
0 commit comments