Windowify this #612
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
on: | |
push: | |
branches-ignore: | |
- master | |
workflow_dispatch: | |
name: Deploy commit to beta | |
jobs: | |
deploy_commit: | |
name: Deploy commit to Beta | |
if: ${{ (github.event_name != 'release' && github.event.action != 'created') && (github.event_name == 'push' && contains(github.event.head_commit.message, '--BETA') && (github.event.head_commit.author.username == 'V13Axel' || github.event.head_commit.author.username == 'Haxxer')) || github.event_name == 'workflow_dispatch' }} | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mariadb:10.3 | |
env: | |
MYSQL_DATABASE: test_database | |
MYSQL_HOST: 127.0.0.1 | |
MYSQL_USER: admin | |
MYSQL_PASSWORD: rootpass | |
MYSQL_ROOT_PASSWORD: rootpass | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_CHECKOUT_TOKEN }} | |
submodules: 'recursive' | |
- uses: actions/cache@v4 | |
id: cache-npm | |
with: | |
path: | | |
./node_modules/ | |
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} | |
- uses: actions/cache@v4 | |
id: cache-assets | |
with: | |
path: | | |
./public | |
key: ${{ runner.os }}-${{ hashFiles('**/resources') }} | |
- uses: actions/cache@v4 | |
id: cache-composer | |
with: | |
path: | | |
./vendor/ | |
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} | |
- uses: actions/cache@v4 | |
id: cache-env | |
with: | |
path: | | |
./.env | |
key: ${{ runner.os }}-${{ hashFiles('**/.env.github') }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Extract branch name | |
shell: bash | |
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | |
id: extract_branch | |
- uses: "shivammathur/setup-php@v2" | |
with: | |
php-version: "8.1" | |
- uses: "ramsey/composer-install@v2" | |
if: steps.cache-composer.outputs.cache-hit != 'true' | |
- name: Install NPM dependencies | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm install --legacy-peer-deps | |
- name: Build production assets | |
if: steps.cache-assets.outputs.cache-hit != 'true' | |
run: npm run production | |
- name: Create env file | |
if: steps.cache-env.outputs.cache-hit != 'true' | |
run: | | |
php -r "file_exists('.env') || copy('.env.github', '.env');" | |
- name: Generate app_key | |
if: steps.cache-env.outputs.cache-hit != 'true' | |
run: php artisan key:generate | |
# - name: Run unit tests | |
# run: php artisan test | |
- name: Actions Status Discord | |
if: ${{ failure() }} | |
uses: sarisia/[email protected] | |
with: | |
webhook: ${{ secrets.DISCORD_FC_BETA_WEBHOOK }} | |
description: 'Beta deployment unit tests failed' | |
username: "Github" | |
avatar_url: "https://beta.fantasy-calendar.com//resources/header_logo.png" | |
title: "Deploy failure" | |
color: 0xdc2626 | |
nodetail: true | |
- uses: "ramsey/composer-install@v2" | |
with: | |
composer-options: "--prefer-dist --optimize-autoloader --no-dev --ignore-platform-reqs" | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Copy assets into S3 | |
run: | | |
aws s3 sync ./public s3://fantasy-calendar-dev/ | |
- name: Deploy to beta | |
run: npx serverless@3 deploy --stage dev | |
- name: Actions Status Discord | |
uses: sarisia/[email protected] | |
with: | |
webhook: ${{ secrets.DISCORD_FC_BETA_WEBHOOK }} | |
description: 'FC branch ${{ steps.extract_branch.outputs.branch }} deployed to beta' | |
username: "Github" | |
avatar_url: "https://beta.fantasy-calendar.com//resources/header_logo.png" | |
title: "Deploy success" | |
nodetail: true |