Last active
February 5, 2024 20:43
-
-
Save kresnasatya/1465fb496b1b3e0b30f3d32b15e68ee3 to your computer and use it in GitHub Desktop.
Github Action Laravel
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: CI-CD | |
on: push | |
jobs: | |
compile-assets: | |
name: Compile assets | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
# Build jS | |
- name: Setup node | |
uses: actions/setup-node@v1 | |
with: | |
node-version: '12' | |
- name: Install dependencies | |
run: npm ci | |
- name: NPM Build | |
run: | | |
npm run prod | |
cat public/mix-manifest.json # see version in log | |
- name: Upload compile assets | |
uses: actions/upload-artifact@v1 | |
with: | |
name: assets | |
path: public | |
test-php: | |
name: Test/Lint PHP | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@master | |
with: | |
php-version: 7.3 | |
extensions: mbstring, bmath | |
- name: Composer install | |
run: composer install | |
- name: Generate artisan key | |
run: | | |
cp .env.example .env | |
php artisan key:generate | |
- name: Run tests | |
run: ./vendor/bin/phpunit | |
deploy: | |
name: Deploy to production | |
runs-on: ubuntu-latest | |
needs: [compile-assets, test-php] | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Download build assets | |
uses: actions/download-artifact@v1 | |
with: | |
name: assets | |
path: public | |
- name: Setup PHP | |
uses: shivammathur/setup-php@master | |
with: | |
php-version: 7.3 | |
extensions: mbstring, bmath | |
- name: Composer install | |
run: composer install | |
- name: Setup Deployer | |
uses: atymic/deployer-php-action@master | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }} | |
- name: Deploy to Prod | |
run: dep deploy production --tag=${{ env.GITHUB_REF }} -vvv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment