Skip to content

Commit

Permalink
feat: update deployment workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp committed May 29, 2024
1 parent 3733970 commit c67f6d0
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 48 deletions.
65 changes: 41 additions & 24 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,65 @@ on: # yamllint disable-line rule:truthy

name: 🚀 Deploy to production

env:
APP_RUNNER: 'cd app &&'

concurrency: production

jobs:
deployment:
timeout-minutes: 8
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: ["ubuntu-22.04"]
php: ["8.3"]
os:
- ubuntu-latest
php-version:
- '8.3'
dependencies:
- locked
environment:
name: production
url: https://prod.laravel-starter-tpl.wayof.dev

steps:
- name: 🛠️ Setup PHP
uses: shivammathur/setup-php@2.30.4
with:
php-version: ${{ matrix.php-version }}
extensions: curl, libxml, mbstring, zip, fileinfo, decimal, pdo, pdo_mysql
ini-values: error_reporting=E_ALL
coverage: none

- name: 📦 Check out the codebase
uses: actions/checkout@v4
uses: actions/checkout@v4.1.6
with:
fetch-depth: 0

- name: 🛠️ Setup PHP
uses: shivammathur/setup-php@v2
- name: 🛠️ Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: 🤖 Validate composer.json and composer.lock
run: make validate-composer

- name: 🔍 Get composer cache directory
uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.0
with:
php-version: ${{ matrix.php }}
extensions: curl, libxml, mbstring, zip, fileinfo, decimal
ini-values: error_reporting=E_ALL
tools: composer:v2
working-directory: app

- name: ♻️ Restore cached backend dependencies
id: cached-composer-dependencies
uses: actions/cache@v4
- name: ♻️ Restore cached dependencies installed with composer
uses: actions/cache@v4.0.2
with:
path: vendor
key: vendor-${{ runner.os }}-${{ hashFiles('**/composer.lock') }}-${{ matrix.php }}
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-

- name: 📥 Install backend dependencies
if: steps.cached-composer-dependencies.outputs.cache-hit != 'true'
run: cd app && composer install
- name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer
uses: wayofdev/gh-actions/actions/composer/install@v3.1.0
with:
working-directory: app
dependencies: ${{ matrix.dependencies }}

- name: 📤 Deploy production environment
uses: deployphp/action@v1
Expand All @@ -54,14 +75,10 @@ jobs:
deployer-version: 7.4.0
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"
DEPLOYER_PROD_HOST: prod.laravel-starter-tpl.wayof.dev
DEPLOYER_PROD_BRANCH: master

- name: 📦 Create sentry release
uses: getsentry/action-release@v1
Expand Down
65 changes: 41 additions & 24 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,65 @@ on: # yamllint disable-line rule:truthy

name: 🚀 Deploy to staging

env:
APP_RUNNER: 'cd app &&'

concurrency: staging

jobs:
deployment:
timeout-minutes: 8
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: ["ubuntu-22.04"]
php: ["8.3"]
os:
- ubuntu-latest
php-version:
- '8.3'
dependencies:
- locked
environment:
name: staging
url: https://staging.laravel-starter-tpl.wayof.dev

steps:
- name: 🛠️ Setup PHP
uses: shivammathur/setup-php@2.30.4
with:
php-version: ${{ matrix.php-version }}
extensions: curl, libxml, mbstring, zip, fileinfo, decimal, pdo, pdo_mysql
ini-values: error_reporting=E_ALL
coverage: none

- name: 📦 Check out the codebase
uses: actions/checkout@v4
uses: actions/checkout@v4.1.6
with:
fetch-depth: 0

- name: 🛠️ Setup PHP
uses: shivammathur/setup-php@v2
- name: 🛠️ Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: 🤖 Validate composer.json and composer.lock
run: make validate-composer

- name: 🔍 Get composer cache directory
uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.0
with:
php-version: ${{ matrix.php }}
extensions: curl, libxml, mbstring, zip, fileinfo, decimal
ini-values: error_reporting=E_ALL
tools: composer:v2
working-directory: app

- name: ♻️ Restore cached backend dependencies
id: cached-composer-dependencies
uses: actions/cache@v4
- name: ♻️ Restore cached dependencies installed with composer
uses: actions/cache@v4.0.2
with:
path: vendor
key: vendor-${{ runner.os }}-${{ hashFiles('**/composer.lock') }}-${{ matrix.php }}
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-

- name: 📥 Install backend dependencies
if: steps.cached-composer-dependencies.outputs.cache-hit != 'true'
run: cd app && composer install
- name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer
uses: wayofdev/gh-actions/actions/composer/install@v3.1.0
with:
working-directory: app
dependencies: ${{ matrix.dependencies }}

- name: 📤 Deploy staging environment
uses: deployphp/action@v1
Expand All @@ -56,11 +77,7 @@ jobs:
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"
DEPLOYER_STAGING_HOST: staging.laravel-starter-tpl.wayof.dev
DEPLOYER_STAGING_BRANCH: develop

...

0 comments on commit c67f6d0

Please sign in to comment.