-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[frontend] feat: Auto deploy after main merge (#28)
- Loading branch information
1 parent
5ba02f1
commit 8bcaf7f
Showing
4 changed files
with
124 additions
and
30 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,63 @@ | ||
name: Frontend Service Tests - Deploy to Production | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
API_URL: http://localhost:5000 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Use Node.js 18.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
|
||
- name: Start service in docker | ||
run: | | ||
cd ./backend | ||
npm run docker:up | ||
- name: Wait for service to start | ||
run: | | ||
sleep 15 | ||
- name: Test connectivity | ||
run: curl ${API_URL} | ||
|
||
- name: Install and start frontend | ||
run: | | ||
cd ./frontend | ||
npm ci | ||
npm run build | ||
npm run start & | ||
- name: Install Playwright | ||
run: | | ||
cd ./playwright | ||
npm ci | ||
npx playwright install chromium | ||
- name: Run Playwright Tests | ||
run: | | ||
cd ./playwright | ||
npm run test | ||
- name: Stop service in docker | ||
run: | | ||
cd ./backend | ||
npm run docker:down | ||
- name: Deploy FE to production | ||
uses: johnbeynon/[email protected] | ||
with: | ||
service-id: ${{ secrets.MY_RENDER_SERVICE_ID_FE }} | ||
api-key: ${{ secrets.MY_RENDER_API_KEY }} | ||
wait-for-success: true |
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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
name: Frontend Service Tests - Playwright | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
|
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
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 |
---|---|---|
@@ -1,30 +1,40 @@ | ||
import type NoteType from "../types/note"; | ||
|
||
interface NoteProps { | ||
note: NoteType; | ||
handleEdit: () => void; | ||
deleteNote: () => void; | ||
note: NoteType; | ||
handleEdit: () => void; | ||
deleteNote: () => void; | ||
} | ||
|
||
const Note: React.FC<NoteProps> = ({ note, handleEdit, deleteNote }) => { | ||
const handleDeleteMouseDown = (e: React.MouseEvent<HTMLButtonElement>) => { | ||
// Prevent the click event from propagating to the parent container | ||
e.stopPropagation(); | ||
|
||
const handleDeleteMouseDown = (e: React.MouseEvent<HTMLButtonElement>) => { | ||
// Prevent the click event from propagating to the parent container | ||
e.stopPropagation(); | ||
|
||
// Call the deleteNote function | ||
deleteNote(); | ||
}; | ||
return ( | ||
<div data-testid="note" className="note-item" onClick={handleEdit}> | ||
<h3 data-testid="note-title">{note.title}</h3> | ||
<p className="note-content" data-testid="note-content">{note.content}</p> | ||
<p className="note-updated" data-testid="note-updated">Updated {new Date(note.updatedAt ?? "").toLocaleDateString()}</p> | ||
<div className="notes-header"> | ||
<button data-testid='note-delete-button' onClick={handleDeleteMouseDown}>X</button> | ||
</div> | ||
</div> | ||
); | ||
// Call the deleteNote function | ||
deleteNote(); | ||
}; | ||
return ( | ||
<div data-testid="note" className="note-item" onClick={handleEdit}> | ||
<h3 className="note-title" data-testid="note-title"> | ||
{note.title} | ||
</h3> | ||
<p className="note-content" data-testid="note-content"> | ||
{note.content} | ||
</p> | ||
<div className="notes-header"> | ||
<p className="note-updated" data-testid="note-updated"> | ||
Updated {new Date(note.updatedAt ?? "").toLocaleDateString()} | ||
</p> | ||
<button | ||
data-testid="note-delete-button" | ||
onClick={handleDeleteMouseDown} | ||
> | ||
X | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Note; |
8bcaf7f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage for this commit
Coverage Report