Update package.json #19
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: Front End - Build and Deploy to Netlify | |
on: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- 'Front-End/**' | |
defaults: | |
run: | |
working-directory: ./Front-End | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Repository Checkout | |
uses: actions/checkout@v4 | |
# - name: Setup NodeJS | |
# uses: actions/setup-node@v4 | |
# with: | |
# node-version: '20.x' | |
# cache: 'npm' | |
# cache-dependency-path: './Front-End/package-lock.json' | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | |
name: List the state of node modules | |
continue-on-error: true | |
run: npm list | |
- name: Create env file | |
run: | | |
touch .env | |
echo "${{ secrets.FRONT_END_ENV }}" > .env | |
- name: Install Dependencies | |
run: npm install | |
- name: Build project | |
run: npm run build | |
- name: Deploy to Netlify | |
id: netlify_deploy | |
run: | | |
npm exec netlify-cli deploy \ | |
--dir dist \ | |
--site ${{ secrets.NETLIFY_SITE_ID }} \ | |
--auth ${{ secrets.NETLIFY_API_TOKEN }} \ | |
--prod |