Merge pull request #22 from raferdev/development #34
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: Build and Deploy | |
concurrency: | |
group: production | |
cancel-in-progress: true | |
on: | |
push: | |
branches: [main] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node & Pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8.9.2 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
cache: 'pnpm' | |
- name: Create env file | |
run: | | |
echo "${{ secrets.ENV_FILE }}" > .env | |
echo "${{ secrets.ENV_LOCAL_FILE }}" > .env.local | |
- name: Install Deps | |
run: pnpm i | |
- name: Build | |
run: pnpm run build | |
- name: Build Storybook | |
run: pnpm run build.storybook | |
- name: Upload Landing Page Files | |
uses: actions/upload-artifact@v3 | |
with: | |
name: landing-page | |
path: out | |
retention-days: 1 | |
- name: Upload Storybook Files | |
uses: actions/upload-artifact@v3 | |
with: | |
name: storybook | |
path: storybook-static | |
retention-days: 1 | |
deploy: | |
name: Deploy | |
runs-on: self-hosted | |
needs: build | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download Storybook | |
uses: actions/download-artifact@v3 | |
with: | |
name: storybook | |
path: storybook-static | |
- name: Download Landing Page | |
uses: actions/download-artifact@v3 | |
with: | |
name: landing-page | |
path: out | |
- name: Filter | |
uses: dorny/[email protected] | |
id: filter | |
with: | |
filters: | | |
ngnix: | |
- '**/*' | |
- name: Deploy Nginx | |
if: ${{ steps.filter.outputs.ngnix }} == 'true' | |
run: | | |
sudo docker compose -f docker-compose.yaml build --no-cache | |
sudo docker compose down | |
sudo docker compose up -d | |
- name: Update content | |
run: | | |
sudo docker cp ./out nginx_server:/www/data/ | |
sudo docker cp ./storybook-static nginx_server:/www/data/ |