Skip to content

Commit

Permalink
new deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
SethSharp committed Mar 27, 2024
1 parent d5f8894 commit 6caf614
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Deploy
on: [ push ]

jobs:
tests-and-deploy-steps:
run-tests:

runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

env:
DB_DATABASE: testing
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
vendor/bin/php-cs-fixer fix
- name: Copy .env
run: php -r "file_exists('.env') || copy('.deployment.env.example', '.env');"
run: php -r "file_exists('.env') || copy('.env.example', '.env');"

- name: Generate key
run: php artisan key:generate
Expand All @@ -65,22 +65,29 @@ jobs:
DB_PASSWORD: root
run: php artisan test

deploy-staging:
if: github.ref == 'refs/heads/main'

runs-on: ubuntu-22.04

steps:
- name: Copy .env
run: php -r "file_exists('.env') || copy('staging.env.example', '.env');"

- name: Generate key
run: php artisan key:generate

- name: Echo URL to .env
if: github.ref == 'refs/heads/main'
run: |
echo "APP_URL=http://habittracker-uc-1.eba-ayudv8jf.ap-southeast-2.elasticbeanstalk.com" >> .env
echo "DB_HOST=${{ secrets.DB_HOST}}" >> .env
echo "DB_PORT=3306" >> .env
echo "DB_DATABASE=${{ secrets.DB_DATABASE}}" >> .env
echo "DB_USERNAME=${{ secrets.DB_USERNAME}}" >> .env
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD}}" >> .env
- name: Build ZIP Deployment Package
if: github.ref == 'refs/heads/main'
run: zip -r deploy.zip ./ -x "node_modules/*" -x "vendor/*" -x "tests/*"

- name: Deploy to Elastic Beanstalk
if: github.ref == 'refs/heads/main'
- name: Deploy to Staging Elastic Beanstalk
uses: einaregilsson/beanstalk-deploy@v18
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY }}
Expand Down
2 changes: 2 additions & 0 deletions .deployment.env.example → staging.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
APP_NAME="Habit Tracker"
APP_ENV=production
APP_KEY=
APP_URL=http://habittracker-uc-1.eba-ayudv8jf.ap-southeast-2.elasticbeanstalk.com

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
Expand Down Expand Up @@ -50,3 +51,4 @@ VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

DB_CONNECTION=mysql
DB_HOST=3306

0 comments on commit 6caf614

Please sign in to comment.