name: Laravel Deploy Preview
on:
pull_request:
types: [opened, synchronize, closed] # Added 'closed' for potential tear-down
permissions:
contents: read
pull-requests: write # Needed for commenting on PRs and potentially tear-down
jobs:
deploy-preview:
# This 'if' condition ensures the job only runs
# when the PR's target (base) branch is 'PR-review-code'.
if: github.base_ref == 'PR-review-code'
runs-on: ubuntu-latest
steps:
- name: ✅ Checkout code
uses: actions/checkout@v3
- name: 🕵️ Print PR info
run: |
echo "🧵 HEAD REF (Source Branch): ${{ github.head_ref }}"
echo "🔀 BASE REF (Target Branch): ${{ github.base_ref }}"
echo "🧑💻 PR Number: ${{ github.event.pull_request.number }}"
echo "🧾 Event name: ${{ github.event_name }}"
- name: Debug PR Info
run: |
echo "HEAD REF: ${{ github.head_ref }}"
echo "BASE REF: ${{ github.base_ref }}"
echo "PR Number: ${{ github.event.pull_request.number }}"
echo "Event Name: ${{ github.event_name }}"
- name: 🧪 Test Forge API token (list servers)
run: |
echo "🔐 Testing Forge Token..."
# Using jq to pretty-print the JSON response for readability in logs
# This step helps confirm your FORGE_TOKEN is valid and can access Forge.
curl -s -H "Authorization: Bearer ${{ secrets.FORGE_TOKEN }}" https://forge.laravel.com/api/v1/servers | jq
env:
FORGE_TOKEN: ${{ secrets.FORGE_TOKEN }} # Ensure FORGE_TOKEN is available as an environment variable for curl
- name: 🐛 Enable debug logs
run: |
echo "DEBUG=true" >> $GITHUB_ENV
echo "ACTIONS_STEP_DEBUG=true" >> $GITHUB_ENV
- name: 🚀 Deploy to Laravel Forge
uses: bakerkretzmar/laravel-deploy-preview@v2
with:
forge-token: ${{ secrets.FORGE_TOKEN }}
github-token: ${{ github.token }}
# --- CORRECTED 'servers' INPUT FORMAT (per action.yml) ---
# 'Each line must contain a domain name and a Forge server ID separated by a space.'
# Example: test-api.gravitywrite.com 123456
# IMPORTANT: REPLACE 'YOUR_NUMERIC_FORGE_SERVER_ID_HERE' with your actual numeric server ID!
servers: |
test-api.gravitywrite.com 87654
# --- CORRECTED 'aliases' INPUT FORMAT (per action.yml) ---
# 'Enter multiple aliases on separate lines.'
# These aliases will be added *in addition* to the main domain.
aliases: |
pr-${{ github.event.number }}.test-api.gravitywrite.com
# hardcoded-specific-url.test-api.gravitywrite.com # Example of another alias
# --- OTHER INPUTS (as per action.yml) ---
isolated: true
no-certificate: false
php-version: '8.2' # From the action.yml, this is a top-level input
# Shell script to append and run after the default Forge deploy script.
after-deploy: |
echo "✅ Forge preview site deployed!"
# Add any other post-deployment commands here, e.g.:
# php artisan migrate --force
# php artisan db:seed --force
# npm install
# npm run build
# Optional: You can add environment variables if needed
# environment: |
# APP_ENV=pr
# APP_DEBUG=true
# Optional: Deployment webhooks or failure emails
# deployment-webhooks: |
# https://example.com/webhook
# deployment-failure-emails: |
# your-email@example.com
This is the script i am using in my branch but script is successful but site creation not happening may i know reason please !
name: Laravel Deploy Preview
on:
pull_request:
types: [opened, synchronize, closed] # Added 'closed' for potential tear-down
permissions:
contents: read
pull-requests: write # Needed for commenting on PRs and potentially tear-down
jobs:
deploy-preview:
# This 'if' condition ensures the job only runs
# when the PR's target (base) branch is 'PR-review-code'.
if: github.base_ref == 'PR-review-code'
runs-on: ubuntu-latest
This is the script i am using in my branch but script is successful but site creation not happening may i know reason please !