Merge pull request #145 from coledykstra/main #47
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: Build and Test Laravel Project | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
phpunit: | |
runs-on: ubuntu-latest | |
container: | |
image: kirschbaumdevelopment/laravel-test-runner:8.2 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 1 | |
- name: create test sqlite database | |
run: | | |
touch database/database.sqlite | |
- name: create permissions | |
run: | | |
chown -R $(id -u):$(id -g) . | |
- name: Install front-end dependencies | |
run: | | |
npm install | |
npm run build | |
env: | |
USER: root | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CI: true | |
- name: Install composer dependencies | |
run: | | |
composer update | |
composer install | |
- name: Prepare Laravel Application | |
run: | | |
cp .env.testing .env | |
php artisan migrate:fresh --env=testing | |
- name: Generate Key | |
run: php artisan key:generate --env=testing | |
- name: Run Testsuite | |
env: | |
CANVAS_API_KEY: ${{ secrets.CANVAS_API_KEY }} | |
CI: true | |
run: php artisan test | |
deploy: | |
name: Deploy to EC2 | |
runs-on: ubuntu-latest | |
needs: [phpunit] | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' && github.repository == 'UnlockedLabs/UnlockEdv2' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build & Deploy | |
env: | |
PRIVATE_KEY: ${{ secrets.DEPLOY_KEY }} | |
HOSTNAME: ${{ secrets.SSH_HOST }} | |
USER_NAME: ${{ secrets.USER_NAME }} | |
run: | | |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key | |
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} '~/deploy.sh' |