diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bb93a95..116171d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,21 +2,20 @@ name: Deploy on: push: - branches: [ main, production ] + branches: [ staging, production ] jobs: - lint: + deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.2' - - - name: Install dependencies - run: composer install --prefer-dist --no-progress - - - name: Check PHP syntax - run: find . -type f -name '*.php' -print0 | xargs -0 -n1 php -l \ No newline at end of file + - uses: actions/checkout@v2 + + - name: Deploy to Forge + env: + FORGE_API_TOKEN: ${{ secrets.FORGE_API_TOKEN }} + run: | + if [[ $GITHUB_REF == "refs/heads/production" ]]; then + curl -X POST ${{ secrets.FORGE_PRODUCTION_DEPLOY_URL }} + elif [[ $GITHUB_REF == "refs/heads/staging" ]]; then + curl -X POST ${{ secrets.FORGE_STAGING_DEPLOY_URL }} + fi \ No newline at end of file diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 29d1f12..708e6ff 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -2,10 +2,10 @@ ## Local Development -1. Make sure you're on main branch: +1. Make sure you're on staging branch: ```bash -git checkout main -git pull origin main +git checkout staging +git pull origin staging ``` 2. Make changes and test locally: @@ -17,7 +17,7 @@ git pull origin main ```bash git add . git commit -m "Descriptive message" -git push origin main +git push origin staging ``` ## Staging Deployment @@ -36,7 +36,7 @@ git push origin main After verifying on staging: ```bash git checkout production -git merge main +git merge staging git push origin production ``` @@ -88,7 +88,7 @@ git revert HEAD # or git reset --hard HEAD^ -git push origin main --force +git push origin staging --force ``` 2. Production Rollback: @@ -103,7 +103,7 @@ git push origin production --force # Get file from previous commit git checkout HEAD^ -- path/to/file git commit -m "Rollback file to previous version" -git push origin main # for staging +git push origin staging # for staging # or git push origin production # for production ``` diff --git a/README.md b/README.md index b3d3e29..47f9f8b 100644 --- a/README.md +++ b/README.md @@ -28,40 +28,42 @@ php db/init.php ## Deployment -The site uses Laravel Forge for deployment. The deployment process is: +1. Push changes to the `staging` branch for testing +2. Once tested, merge to `production` branch for production deployment -1. Push changes to the `main` branch for staging -2. Push changes to the `production` branch for live site +## Branches -### Branch Strategy +- `staging`: Development branch, deploys to staging +- `production`: Production branch, deploys to production -- `main`: Development branch, deploys to staging -- `production`: Production branch, deploys to live site -- `feature/*`: Feature branches -- `fix/*`: Bug fix branches +## Development Workflow -### Deployment Process - -1. Create feature branch: +1. Clone the repository and checkout staging branch: ```bash -git checkout main -git pull origin main -git checkout -b feature/your-feature +git clone https://github.com/screenfluent/llmstxtdirectory.git +cd llmstxtdirectory +git checkout staging +git pull origin staging ``` -2. Make changes and test locally +2. Make your changes and commit them: +```bash +git add . +git commit -m "Your commit message" +``` 3. Push to staging: ```bash -git checkout main -git merge feature/your-feature -git push origin main +git checkout staging +git pull origin staging +git push origin staging ``` -4. After testing on staging, deploy to production: +4. After testing on staging, merge to production: ```bash git checkout production -git merge main +git pull origin production +git merge staging git push origin production ``` diff --git a/deploy.sh b/deploy.sh index aef4baa..cc3b855 100644 --- a/deploy.sh +++ b/deploy.sh @@ -4,7 +4,7 @@ php artisan down || true # Pull the latest changes from the git repository -git pull origin main +git pull origin staging # Install/update composer dependencies composer install --no-interaction --prefer-dist --optimize-autoloader diff --git a/forge/deploy.staging.sh b/forge/deploy.staging.sh index 56ac6e7..dc152e7 100644 --- a/forge/deploy.staging.sh +++ b/forge/deploy.staging.sh @@ -11,8 +11,8 @@ cd /home/stagingllmstxtdirectory/staging.llmstxt.directory # Initial git setup git fetch --all -git checkout -f staging || git checkout -f main -git pull origin staging || git pull origin main +git checkout -f staging +git pull origin staging # Set permissions chown -R stagingllmstxtdirectory:stagingllmstxtdirectory .