Skip to content

Commit

Permalink
[MERGE] Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Bilotta committed Feb 23, 2021
2 parents 73d9e85 + f1670bd commit 9b0f140
Show file tree
Hide file tree
Showing 17 changed files with 811 additions and 575 deletions.
101 changes: 101 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Deploy to Production
on:
push:
branches:
- production

jobs:
build:
name: Build process
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Install Node.js 15
uses: actions/setup-node@v1
with:
node-version: 15

- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: yarn ci
- name: Lint project
run: yarn lint:prod
# - name: Run tests
# run: yarn test
# - name: Build server files
# run: yarn build
- name: Generate static files
run: yarn generate
- name: Create artifact
run: |
PACKAGE_VERSION=`node -e "console.log(require('./package.json').version);"`
PACKAGE_NAME="byloth-website-v${PACKAGE_VERSION}.tgz"
yarn pack
tar -xzvf "${PACKAGE_NAME}" -C "."
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: byloth-website
path: package/dist

#
# test:
# name: Test process
# needs: build
# runs-on: ubuntu-latest
# steps:
# - [...]
#

deploy:
name: Deploy process
needs: build
runs-on: ubuntu-latest
environment:
name: production

steps:
- name: Install CurlFtpFS
run: sudo apt install curlftpfs
- name: Mount remote FTP directory
shell: bash
run: |
sudo mkdir -p "${VOLUME}"
sudo chown $(id -u):$(id -g) "${VOLUME}"
curlftpfs "${FTP_HOST}" "${VOLUME}" -o "user=${FTP_USER}:${FTP_PASS}"
env:
VOLUME: /mnt/byloth-website
FTP_HOST: ${{ secrets.FTP_HOST }}
FTP_USER: ${{ secrets.FTP_USER }}
FTP_PASS: ${{ secrets.FTP_PASS }}

- name: Download artifact
uses: actions/download-artifact@v2
with:
name: byloth-website
path: dist

- name: Compose `env.php` file
shell: bash
run: |
echo "<?php" > "${ENV_FILE}"
echo "define('__RECIPIENT__', '${EMAIL_RECIPIENT}');" >> "${ENV_FILE}"
echo "define('__SENDER__', '${EMAIL_SENDER}');" >> "${ENV_FILE}"
env:
ENV_FILE: dist/api/env.php
EMAIL_RECIPIENT: ${{ secrets.EMAIL_RECIPIENT }}
EMAIL_SENDER: ${{ secrets.EMAIL_SENDER }}

- name: Replace directory content
shell: bash
run: |
shopt -s dotglob
rm -rfv "${VOLUME}/*"
cp -rfv dist/* "${VOLUME}/"
env:
VOLUME: /mnt/byloth-website
101 changes: 101 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Deploy to Staging
on:
push:
branches:
- staging

jobs:
build:
name: Build process
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Install Node.js 15
uses: actions/setup-node@v1
with:
node-version: 15

- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: yarn ci
- name: Lint project
run: yarn lint:prod
# - name: Run tests
# run: yarn test
# - name: Build server files
# run: yarn build
- name: Generate static files
run: yarn generate
- name: Create artifact
run: |
PACKAGE_VERSION=`node -e "console.log(require('./package.json').version);"`
PACKAGE_NAME="byloth-website-v${PACKAGE_VERSION}.tgz"
yarn pack
tar -xzvf "${PACKAGE_NAME}" -C "."
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: byloth-website
path: package/dist

#
# test:
# name: Test process
# needs: build
# runs-on: ubuntu-latest
# steps:
# - [...]
#

deploy:
name: Deploy process
needs: build
runs-on: ubuntu-latest
environment:
name: staging

steps:
- name: Install CurlFtpFS
run: sudo apt install curlftpfs
- name: Mount remote FTP directory
shell: bash
run: |
sudo mkdir -p "${VOLUME}"
sudo chown $(id -u):$(id -g) "${VOLUME}"
curlftpfs "${FTP_HOST}" "${VOLUME}" -o "user=${FTP_USER}:${FTP_PASS}"
env:
VOLUME: /mnt/byloth-website
FTP_HOST: ${{ secrets.FTP_HOST }}
FTP_USER: ${{ secrets.FTP_USER }}
FTP_PASS: ${{ secrets.FTP_PASS }}

- name: Download artifact
uses: actions/download-artifact@v2
with:
name: byloth-website
path: dist

- name: Compose `env.php` file
shell: bash
run: |
echo "<?php" > "${ENV_FILE}"
echo "define('__RECIPIENT__', '${EMAIL_RECIPIENT}');" >> "${ENV_FILE}"
echo "define('__SENDER__', '${EMAIL_SENDER}');" >> "${ENV_FILE}"
env:
ENV_FILE: dist/api/env.php
EMAIL_RECIPIENT: ${{ secrets.EMAIL_RECIPIENT }}
EMAIL_SENDER: ${{ secrets.EMAIL_SENDER }}

- name: Replace directory content
shell: bash
run: |
shopt -s dotglob
rm -rfv "${VOLUME}/*"
cp -rfv dist/* "${VOLUME}/"
env:
VOLUME: /mnt/byloth-website
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ Desktop.ini
#
/.nuxt/
/dist/

/*.tgz
/static/sw.js

# Environmental files
#
.env
env.php

# Downloadable & installable modules & components
#
/node_modules/
Expand Down
35 changes: 35 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Files created by OS
#
.DS_Store
Desktop.ini

# Files created by IDE
#
/.idea/
/.vscode/

/*.code-workspace

# Generated & compiled files
#
/*.tgz
/static/sw.js

# Config files
#
/.editorconfig
/.eslintrc.js

/jsconfig.json
/nuxt.config.js
/tsconfig.json

# Environmental files
#
.env
env.php

# Useless files
#
README.md
/.github/
Loading

0 comments on commit 9b0f140

Please # to comment.