-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
paths: | ||
- frontend/** | ||
|
||
jobs: | ||
react_test_and_lint: | ||
name: Test and Lint React app | ||
runs-on: self-hosted | ||
steps: | ||
- name: Checkout the files | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '20.3.1' | ||
|
||
# Caching dependencies to speed up subsequent runs | ||
- name: Restore cached dependencies | ||
id: cache-restore | ||
uses: actions/cache@v3 | ||
with: | ||
path: ./frontend/node_modules | ||
key: npm-${{ hashFiles('frontend/package-lock.json') }} | ||
restore-keys: | | ||
npm- | ||
- name: Install dependencies | ||
if: steps.cache-restore.outputs.cache-hit != 'true' | ||
run: | | ||
cd frontend | ||
npm ci --ignore-scripts | ||
# Run tests if they are set up (assuming `npm test` is configured in package.json) | ||
- name: Test with Jest | ||
run: | | ||
cd frontend | ||
npm run test -- --watchAll=false | ||
# Run ESLint for code quality | ||
- name: Run ESLint | ||
run: | | ||
cd frontend | ||
npm run lint | ||
# Build the app to ensure there are no build errors | ||
- name: Build the Vite app | ||
run: | | ||
cd frontend | ||
npm run build | ||
# Optional Docker build job if containerization is required | ||
docker_build: | ||
name: Build Docker Image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the files | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build Docker Image | ||
run: | | ||
docker build -t react-app:latest frontend/ | ||
- name: Push Docker Image | ||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
run: | | ||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | ||
docker tag react-app:latest your-docker-repo/react-app:latest | ||
docker push your-docker-repo/react-app:latest |