Last active
August 22, 2021 21:42
-
-
Save oceanapplications/31e9aa6134214ef3005181d7dc537c54 to your computer and use it in GitHub Desktop.
This file contains hidden or 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: Laravel | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
laravel-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e | |
with: | |
php-version: '8.0' | |
- uses: actions/checkout@v2 # gets repo | |
- name: Copy .env | |
run: php -r "file_exists('.env') || copy('.env.example', '.env');" # sets up env | |
- name: Install Dependencies | |
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | |
- name: Generate key | |
run: php artisan key:generate | |
- name: Directory Permissions | |
run: chmod -R 777 storage bootstrap/cache | |
- name: Create Database | |
run: | | |
mkdir -p database | |
touch database/database.sqlite | |
- name: Execute tests (Unit and Feature tests) via PHPUnit | |
env: # overrides env to use sqlite | |
DB_CONNECTION: sqlite | |
DB_DATABASE: database/database.sqlite | |
run: vendor/bin/phpunit | |
docker: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
needs: laravel-tests | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout # gets repo | |
uses: actions/checkout@v2 | |
- | |
name: Set up QEMU # needed for docker | |
uses: docker/setup-qemu-action@v1 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- | |
name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: # secrets are set in your github repo settings. The tokens can be generated here: https://hub.docker.com/settings/security | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- | |
name: Build and push app image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: s937717/laravel:latest # this needs to match the repo you created in docker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment