Created
November 7, 2024 16:09
-
-
Save jonerickson/b30a45411cf328de6eed3cdb7ab15bd5 to your computer and use it in GitHub Desktop.
Vapor Deploy
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: Deploy Application | |
env: | |
SIDECAR_APP_NAME: ${{ secrets.SIDECAR_APP_NAME }} | |
SIDECAR_ACCESS_KEY_ID: ${{ secrets.SIDECAR_ACCESS_KEY_ID }} | |
SIDECAR_SECRET_ACCESS_KEY: ${{ secrets.SIDECAR_SECRET_ACCESS_KEY }} | |
SIDECAR_REGION: ${{ secrets.SIDECAR_REGION }} | |
SIDECAR_ARTIFACT_BUCKET_NAME: ${{ secrets.SIDECAR_ARTIFACT_BUCKET_NAME }} | |
SIDECAR_EXECUTION_ROLE: ${{ secrets.SIDECAR_EXECUTION_ROLE }} | |
VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }} | |
VITE_PUSHER_HOST: ${{ secrets.PUSHER_HOST }} | |
VITE_PUSHER_PORT: ${{ secrets.PUSHER_PORT }} | |
VITE_PUSHER_SCHEME: ${{ secrets.PUSHER_SCHEME }} | |
VITE_PUSHER_APP_CLUSTER: ${{ secrets.PUSHER_APP_CLUSTER }} | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- '*' | |
jobs: | |
production: | |
name: Deploy Application to Production | |
runs-on: ubuntu-latest | |
if: (contains(github.ref, 'tags') && ! contains(github.ref, 'prerelease')) || github.ref == 'refs/heads/master' | |
environment: | |
name: production | |
url: https://eliosfund.com | |
steps: | |
- name: Checkout Source Code | |
uses: actions/checkout@v3 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.2 | |
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite | |
ini-values: error_reporting=E_ALL | |
tools: composer | |
coverage: xdebug | |
- name: Get Composer Cache Directory | |
id: composer-cache | |
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- name: Configure Composer Authentication | |
run: echo '${{ secrets.COMPOSER_AUTH_JSON }}' > $GITHUB_WORKSPACE/auth.json | |
- name: Cache Composer Dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-composer- | |
- name: Install PHP Dependencies | |
run: composer install --prefer-dist --no-interaction --no-progress --no-scripts | |
- name: Setup Node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
- name: Install NCC | |
run: npm install -g @vercel/ncc | |
- name: Build Lambda Functions | |
run: | | |
for dir in resources/lambda/*/; do | |
echo "Building function in $dir" | |
cd $dir | |
if [ -f package.json ]; then | |
npm ci | |
ncc build index.js -o dist | |
else | |
echo "No package.json found in $dir, skipping" | |
fi | |
cd - > /dev/null | |
done | |
- name: Install Vapor CLI | |
run: composer global require laravel/vapor-cli --update-with-dependencies | |
- name: Deploy Application | |
env: | |
VITE_GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY_PRODUCTION }} | |
VITE_PUSHER_APP_KEY: ${{ secrets.PUSHER_APP_KEY_PRODUCTION }} | |
run: vapor deploy production | |
staging: | |
name: Deploy Application to Staging | |
runs-on: ubuntu-latest | |
if: contains(github.ref, 'prerelease') || github.ref == 'refs/heads/staging' | |
environment: | |
name: staging | |
url: https://staging.eliosfund.com | |
steps: | |
- name: Checkout Source Code | |
uses: actions/checkout@v3 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.2 | |
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite | |
ini-values: error_reporting=E_ALL | |
tools: composer | |
coverage: xdebug | |
- name: Get Composer Cache Directory | |
id: composer-cache | |
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- name: Configure Composer Authentication | |
run: echo '${{ secrets.COMPOSER_AUTH_JSON }}' > $GITHUB_WORKSPACE/auth.json | |
- name: Cache Composer Dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-composer- | |
- name: Install PHP Dependencies | |
run: composer install --prefer-dist --no-interaction --no-progress --no-scripts | |
- name: Setup Node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
- name: Install NCC | |
run: npm install -g @vercel/ncc | |
- name: Build Lambda Functions | |
run: | | |
for dir in resources/lambda/*/; do | |
echo "Building function in $dir" | |
cd $dir | |
if [ -f package.json ]; then | |
npm ci | |
ncc build index.js -o dist | |
else | |
echo "No package.json found in $dir, skipping" | |
fi | |
cd - > /dev/null | |
done | |
- name: Install Vapor CLI | |
run: composer global require laravel/vapor-cli --update-with-dependencies | |
- name: Deploy Application | |
env: | |
VITE_GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY_STAGING }} | |
VITE_PUSHER_APP_KEY: ${{ secrets.PUSHER_APP_KEY_STAGING }} | |
run: vapor deploy staging |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment