Add CI/CD workflow for React to AWS Amplify
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
name: CI/CD for React to AWS Amplify
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# Testing
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-cache: 'npm' # Optimizes subsequent runs
|
||||||
|
node-version: 18
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Run Linter (Optional but recommended)
|
||||||
|
run: npm run lint --if-present
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
run: npm test -- --watchAll=false # Ensures CI doesn't hang on watch mode
|
||||||
|
|
||||||
|
# Deployment (Only runs if 'test' passes)
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Trigger Amplify Webhook
|
||||||
|
run: curl -X POST -d {} "${{ secrets.AMPLIFY_WEBHOOK_URL }}"
|
||||||
Reference in New Issue
Block a user