diff --git a/.github/workflows/deploy_note_app.yml b/.github/workflows/deploy_note_app.yml
index ab3a86b..48b928e 100644
--- a/.github/workflows/deploy_note_app.yml
+++ b/.github/workflows/deploy_note_app.yml
@@ -20,10 +20,10 @@ jobs:
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
- uses: actions/checkout@v4
+ uses: actions/checkout@v4.1.7
- name: Set up Node.js
- uses: actions/setup-node@v4
+ uses: actions/setup-node@v4.0.3
with:
node-version: 20
cache: 'npm'
@@ -71,16 +71,16 @@ jobs:
SECRET: ${{ secrets.SECRET }}
- name: Upload Playwright report
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v4.3.4
if: always()
with:
name: playwright-report
path: part3/notes_fullstack/playwright-report/
- retention-days: 30
+ retention-days: 10
- name: Upload build artifact for deployment
if: github.event_name == 'push'
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v4.3.4
with:
name: production-build
path: part3/notes_fullstack/dist
@@ -95,17 +95,17 @@ jobs:
id-token: 'write' # Required for Workload Identity Federation
steps:
- name: Checkout repository
- uses: actions/checkout@v4
+ uses: actions/checkout@v4.1.7
- name: Download build artifact
- uses: actions/download-artifact@v4
+ uses: actions/download-artifact@v4.1.8
with:
name: production-build
path: part3/notes_fullstack/dist
- name: Authenticate to Google Cloud
id: auth
- uses: 'google-github-actions/auth@v2'
+ uses: 'google-github-actions/auth@v2.1.3'
with:
workload_identity_provider: ${{ secrets.GCP_WIF_PROVIDER }}
service_account: ${{ secrets.GCP_SA_EMAIL }}
@@ -124,4 +124,27 @@ jobs:
--image ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE_NAME }}/${{ env.SERVICE_NAME }}:${{ github.sha }} \
--region ${{ env.REGION }} \
--allow-unauthenticated \
- --set-env-vars "MONGODB_URI=${{ secrets.MONGODB_URI }},SECRET=${{ secrets.SECRET }}"
\ No newline at end of file
+ --set-env-vars "MONGODB_URI=${{ secrets.MONGODB_URI }},SECRET=${{ secrets.SECRET }}"
+
+ tag_release:
+ name: Tag Release
+ needs: [deploy]
+ runs-on: ubuntu-24.04
+ permissions:
+ contents: 'write' # Required to push new tags
+ # Skip tagging if the commit message contains #skip for push events on the target branch
+ if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '#skip') }}
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4.1.7
+
+ - name: Bump version and push tag
+ id: tag_version
+ uses: anothrNick/github-tag-action@1.73.0
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ TAG_PREFIX: v
+ DEFAULT_BUMP: patch
+
+ - name: Log new tag
+ run: echo "New tag is ${{ steps.tag_version.outputs.tag }}"
\ No newline at end of file
diff --git a/part2/notes_frontend/src/App.jsx b/part2/notes_frontend/src/App.jsx
index 5574e2d..3a3139b 100644
--- a/part2/notes_frontend/src/App.jsx
+++ b/part2/notes_frontend/src/App.jsx
@@ -2,11 +2,12 @@ import { useState, useEffect, useRef } from 'react'
// Services
import noteService from './services/notes'
import loginService from './services/login'
+import userService from './services/users'
// Ui components
import Notification from './components/Notification'
import Footer from './components/Footer'
-import { LoginForm, NoteForm } from './components/Forms'
+import { LoginForm, NoteForm, SignUpForm } from './components/Forms'
import NotesList from './components/NoteList'
import Togglable from './components/Togglable'
@@ -59,6 +60,21 @@ const App = () => {
}
}
+ const signUpApp = async (userObject) => {
+ try {
+ await userService.create(userObject)
+ setErrorMessage(`User ${userObject.username} created successfully! Please log in.`)
+ setTimeout(() => {
+ setErrorMessage(null)
+ }, 5000)
+ } catch (error) {
+ setErrorMessage(error.response.data.error)
+ setTimeout(() => {
+ setErrorMessage(null)
+ }, 5000)
+ }
+ }
+
const toggleImportanceOf = (id) => {
const note = notes.find(n => n.id === id)
const changedNote = { ...note, important: !note.important }
@@ -102,11 +118,18 @@ const App = () => {
{user.username} logged-in