Skip to content

Deploy to Netlify

Deploy to Netlify #29

Workflow file for this run

name: Test and Build the Application
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.11.1"
- name: Load & cache dependencies
uses: ./.github/actions/cached-deps
- name: Run the linter
run: npm run lint -- --max-warnings=0
test:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.11.1"
- name: Load & cache dependencies
uses: ./.github/actions/cached-deps
- name: Run tests
run: npm test
build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.11.1"
- name: Load & cache dependencies
uses: ./.github/actions/cached-deps
id: chached-deps
- name: Build the application
run: npm run build
- name: Upload artifacts
if: success()
uses: actions/upload-artifact@v4
with:
name: dist-files
path: dist
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Get build artifacts
uses: actions/download-artifact@v4
with:
name: dist-files
path: ./dist
- name: Output files
working-directory: ./dist
run: ls -l
- name: Deploy to Netlify
run: |
npm run netlify deploy \
--dir dist \
--site ${{ secrets.NETLIFY_SITE_ID }} \
--auth ${{ secrets.NETLIFY_API_TOKEN }}
report:
runs-on: ubuntu-latest
needs: [lint, build]
if: failure()
steps:
- name: Output information
run: |
echo "Something went wrong!"
echo "${{ toJson(github)}}"