Skip to content

Commit

Permalink
Merge pull request #16 from wayofdev/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp committed May 9, 2023
2 parents 510fbcc + dbbd0ca commit 107df24
Show file tree
Hide file tree
Showing 11 changed files with 1,788 additions and 291 deletions.
31 changes: 30 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,40 @@ MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_ADDRESS="hello@wayof.dev"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

#######################################
# Sentry
#######################################

SENTRY_LARAVEL_DSN=https://xxxxxxxx@yyyyyyyy.ingest.sentry.io/1234567890
SENTRY_TRACES_SAMPLE_RATE=1.0

#######################################
# Deployer
#######################################

# Create slack app and add incoming webhook urls
# https://api.slack.com/messaging/webhooks
DEPLOYER_STAGING_SLACK_WEBHOOK=https://hooks.slack.com/services/XXXXXXX/XXXXX/XXXXXX
DEPLOYER_STAGING_REMOTE_USER=staging-xxxxx
DEPLOYER_STAGING_HOST=staging.laravel-starter-tpl.wayof.dev
DEPLOYER_STAGING_BRANCH=develop

DEPLOYER_PROD_SLACK_WEBHOOK=https://hooks.slack.com/services/XXXXXXX/XXXXX/XXXXXX
DEPLOYER_PROD_REMOTE_USER=prod-xxxxx
DEPLOYER_PROD_HOST=prod.laravel-starter-tpl.wayof.dev
DEPLOYER_PROD_BRANCH=master

# https://wayofdev.sentry.io/settings/account/api/auth-tokens/
DEPLOYER_SENTRY_TOKEN=50b88fxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DEPLOYER_SENTRY_ORG=wayofdev
DEPLOYER_SENTRY_PROJECT=laravel-starter-tpl
DEPLOYER_SENTRY_SERVER=https://wayofdev.sentry.io
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, fileinfo, gd, xdebug
extensions: dom, curl, libxml, mbstring, zip, fileinfo, xdebug
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: xdebug
Expand All @@ -48,7 +48,7 @@ jobs:
uses: actions/cache@v3
with:
path: vendor
key: vendor-${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
key: vendor-${{ runner.os }}-${{ hashFiles('**/composer.lock') }}-${{ matrix.php }}

- name: 📥 Install backend dependencies
if: steps.cached-composer-dependencies.outputs.cache-hit != 'true'
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/deploy_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---

on: # yamllint disable-line rule:truthy
release:
types:
- released
push:
tags:
- 'v*'

name: 📦 Deploy to production

jobs:
deployment:
runs-on: "ubuntu-22.04"
strategy:
fail-fast: true
matrix:
os: ["ubuntu-22.04"]
php: ["8.1"]
environment:
name: production
url: https://prod.laravel-starter-tpl.wayof.dev

steps:
- name: 📦 Check out the codebase
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: 🛠️ Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, fileinfo
ini-values: error_reporting=E_ALL
tools: composer:v2

- name: ♻️ Restore cached backend dependencies
id: cached-composer-dependencies
uses: actions/cache@v3
with:
path: vendor
key: vendor-${{ runner.os }}-${{ hashFiles('**/composer.lock') }}-${{ matrix.php }}

- name: 📥 Install backend dependencies
if: steps.cached-composer-dependencies.outputs.cache-hit != 'true'
run: cd app && composer install

- name: 📤 Deploy production environment
uses: deployphp/action@v1
with:
private-key: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
dep: deploy prod
deployer-version: 7.3.1
sub-directory: app
env:
DEPLOYER_STAGING_SLACK_WEBHOOK: ${{ secrets.DEPLOYER_STAGING_SLACK_WEBHOOK }}
DEPLOYER_STAGING_REMOTE_USER: ${{ secrets.DEPLOYER_STAGING_REMOTE_USER }}
DEPLOYER_STAGING_HOST: "staging.laravel-starter-tpl.wayof.dev"
DEPLOYER_STAGING_BRANCH: "develop"
DEPLOYER_PROD_SLACK_WEBHOOK: ${{ secrets.DEPLOYER_PROD_SLACK_WEBHOOK }}
DEPLOYER_PROD_REMOTE_USER: ${{ secrets.DEPLOYER_PROD_REMOTE_USER }}
DEPLOYER_PROD_HOST: "prod.laravel-starter-tpl.wayof.dev"
DEPLOYER_PROD_BRANCH: "master"

- name: 📦 Create sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.DEPLOYER_SENTRY_TOKEN }}
SENTRY_ORG: ${{ secrets.DEPLOYER_SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.DEPLOYER_SENTRY_PROJECT }}
with:
environment: ${{ github.ref == 'refs/heads/master' && 'production' || 'staging' }}
set_commits: auto

...
74 changes: 74 additions & 0 deletions .github/workflows/deploy_staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---

on: # yamllint disable-line rule:truthy
push:
branches:
- develop

name: 📦 Deploy to staging

jobs:
deployment:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: ["ubuntu-22.04"]
php: ["8.1"]
environment:
name: staging
url: https://staging.laravel-starter-tpl.wayof.dev

steps:
- name: 📦 Check out the codebase
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: 🛠️ Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, fileinfo
ini-values: error_reporting=E_ALL
tools: composer:v2

- name: ♻️ Restore cached backend dependencies
id: cached-composer-dependencies
uses: actions/cache@v3
with:
path: vendor
key: vendor-${{ runner.os }}-${{ hashFiles('**/composer.lock') }}-${{ matrix.php }}

- name: 📥 Install backend dependencies
if: steps.cached-composer-dependencies.outputs.cache-hit != 'true'
run: cd app && composer install

- name: 📤 Deploy staging environment
uses: deployphp/action@v1
with:
private-key: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
dep: deploy staging
deployer-version: 7.3.1
sub-directory: app
env:
DEPLOYER_STAGING_SLACK_WEBHOOK: ${{ secrets.DEPLOYER_STAGING_SLACK_WEBHOOK }}
DEPLOYER_STAGING_REMOTE_USER: ${{ secrets.DEPLOYER_STAGING_REMOTE_USER }}
DEPLOYER_STAGING_HOST: "staging.laravel-starter-tpl.wayof.dev"
DEPLOYER_STAGING_BRANCH: "develop"
DEPLOYER_PROD_SLACK_WEBHOOK: ${{ secrets.DEPLOYER_PROD_SLACK_WEBHOOK }}
DEPLOYER_PROD_REMOTE_USER: ${{ secrets.DEPLOYER_PROD_REMOTE_USER }}
DEPLOYER_PROD_HOST: "prod.laravel-starter-tpl.wayof.dev"
DEPLOYER_PROD_BRANCH: "master"

- name: 📦 Create sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.DEPLOYER_SENTRY_TOKEN }}
SENTRY_ORG: ${{ secrets.DEPLOYER_SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.DEPLOYER_SENTRY_PROJECT }}
with:
environment: ${{ github.ref == 'refs/heads/master' && 'production' || 'staging' }}
set_commits: auto

...
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,22 @@ update: ## Update composer dependencies
show: ## Shows information about installed composer packages
$(APP_COMPOSER) show
.PHONY: show


# Deployer Commands
# ------------------------------------------------------------------------------------
dep-staging:
$(APP_EXEC) vendor/bin/dep deploy staging
.PHONY: dep-staging

dep-prod:
$(APP_EXEC) vendor/bin/dep deploy prod
.PHONY: dep-prod

ssh-staging:
$(APP_EXEC) vendor/bin/dep ssh staging
.PHONY: ssh-staging

ssh-prod:
$(APP_EXEC) vendor/bin/dep ssh prod
.PHONY: ssh-prod
3 changes: 3 additions & 0 deletions app/app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class Handler extends ExceptionHandler
public function register(): void
{
$this->reportable(function (Throwable $e): void {
if (app()->bound('sentry')) {
app('sentry')->captureException($e);
}
});
}
}
4 changes: 3 additions & 1 deletion app/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"php": "^8.1",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.8",
"laravel/tinker": "^2.8"
"laravel/tinker": "^2.8",
"sentry/sentry-laravel": "^3.3",
"deployer/deployer": "^7.3"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.31",
Expand Down
Loading

0 comments on commit 107df24

Please sign in to comment.