yuk gas #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Production | |
on: | |
push: | |
branches: | |
- main # Ganti dengan branch yang ingin Anda gunakan | |
pull_request: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up SSH | |
uses: webfactory/ssh-agent@v0.5.3 | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} # Tambahkan kunci SSH ke Secrets di GitHub | |
- name: Add Host Key to known_hosts | |
run: | | |
mkdir -p ~/.ssh | |
ssh-keyscan -H 8.219.65.111 >> ~/.ssh/known_hosts | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.3' | |
- name: Install Composer Dependencies | |
run: composer install --optimize-autoloader --no-dev --no-progress --no-interaction --prefer-dist | |
- name: Run Envoy Deployment | |
run: | | |
composer global require laravel/envoy | |
~/.composer/vendor/bin/envoy run deploy --commit="${{ github.sha }}" | |
- name: Rollback if Deployment Fails | |
if: failure() | |
run: | | |
echo "Deployment failed. Rolling back to previous version." | |
~/.composer/vendor/bin/envoy run rollback |