From 5800aafe5674882f896020e0279ac4e91beeae77 Mon Sep 17 00:00:00 2001 From: pgarr Date: Tue, 28 Jan 2025 20:37:28 +0100 Subject: [PATCH 1/8] remove README old text --- .github/workflows/{ci.yml => pr_check.yml} | 0 README.md | 68 ---------------------- 2 files changed, 68 deletions(-) rename .github/workflows/{ci.yml => pr_check.yml} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/pr_check.yml similarity index 100% rename from .github/workflows/ci.yml rename to .github/workflows/pr_check.yml diff --git a/README.md b/README.md index 54ef094..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,68 +0,0 @@ -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). - -## Available Scripts - -In the project directory, you can run: - -### `npm start` - -Runs the app in the development mode.
-Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.
-You will also see any lint errors in the console. - -### `npm test` - -Launches the test runner in the interactive watch mode.
-See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `npm run build` - -Builds the app for production to the `build` folder.
-It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.
-Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `npm run eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. - -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. - -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). - -### Code Splitting - -This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting - -### Analyzing the Bundle Size - -This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size - -### Making a Progressive Web App - -This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app - -### Advanced Configuration - -This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration - -### Deployment - -This section has moved here: https://facebook.github.io/create-react-app/docs/deployment - -### `npm run build` fails to minify - -This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify From 2f4047efb13a407ff7db47ac542658ab2ba834e0 Mon Sep 17 00:00:00 2001 From: pgarr Date: Tue, 28 Jan 2025 20:37:42 +0100 Subject: [PATCH 2/8] fix recipe 0 bug --- src/components/Recipes/RecipesDetails/RecipeDetails.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Recipes/RecipesDetails/RecipeDetails.tsx b/src/components/Recipes/RecipesDetails/RecipeDetails.tsx index 73de1a8..54d8fc3 100644 --- a/src/components/Recipes/RecipesDetails/RecipeDetails.tsx +++ b/src/components/Recipes/RecipesDetails/RecipeDetails.tsx @@ -8,7 +8,7 @@ const RecipeDetails = () => { const recipes = useAppSelector((state) => state.recipes.recipes); const loading = useAppSelector((state) => state.recipes.loading); const params = useParams(); - const id = Number(params.id) || -1; + const id = Number(params.id); const selectedRecipe = recipes.find((recipe) => recipe.id === id); return ( From ab9b98383f22ff4c99e89157bd43409cc44e6a7b Mon Sep 17 00:00:00 2001 From: pgarr Date: Tue, 28 Jan 2025 20:47:35 +0100 Subject: [PATCH 3/8] setup firebase and github action for firebase deployment --- .github/workflows/firebase-hosting-merge.yml | 17 +++++++++++++++++ .../firebase-hosting-pull-request.yml | 18 ++++++++++++++++++ .../workflows/{pr_check.yml => pr-checks.yml} | 3 --- .gitignore | 1 + firebase.json | 7 ++++++- 5 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/firebase-hosting-merge.yml create mode 100644 .github/workflows/firebase-hosting-pull-request.yml rename .github/workflows/{pr_check.yml => pr-checks.yml} (86%) diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml new file mode 100644 index 0000000..18b8811 --- /dev/null +++ b/.github/workflows/firebase-hosting-merge.yml @@ -0,0 +1,17 @@ +name: Deploy to Firebase Hosting on merge +on: + push: + branches: + - main +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: npm ci && npm run build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_DEV_COOKING }} + channelId: live + projectId: dev-cooking diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml new file mode 100644 index 0000000..5e4e65d --- /dev/null +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -0,0 +1,18 @@ +name: Deploy to Firebase Hosting on PR +on: pull_request +permissions: + checks: write + contents: read + pull-requests: write +jobs: + build_and_preview: + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: npm ci && npm run build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_DEV_COOKING }} + projectId: dev-cooking diff --git a/.github/workflows/pr_check.yml b/.github/workflows/pr-checks.yml similarity index 86% rename from .github/workflows/pr_check.yml rename to .github/workflows/pr-checks.yml index d5b4d0f..1a211d8 100644 --- a/.github/workflows/pr_check.yml +++ b/.github/workflows/pr-checks.yml @@ -1,8 +1,6 @@ name: CI on: - push: - branches: ["main"] pull_request: branches: ["main"] @@ -23,4 +21,3 @@ jobs: - run: npm ci - run: npm run lint - run: npm test - - run: npm run build --if-present diff --git a/.gitignore b/.gitignore index 0c201aa..2f25631 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ /.firebase .firebaserc +firebase-debug.log database.rules.json sample-data.json diff --git a/firebase.json b/firebase.json index b383baa..65ea27f 100644 --- a/firebase.json +++ b/firebase.json @@ -3,7 +3,12 @@ "rules": "database.rules.json" }, "hosting": { - "public": "build", + "public": "dist", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], "rewrites": [ { "source": "**", From a5d934e39b1b1988d6e111418240dc00ba86e34b Mon Sep 17 00:00:00 2001 From: pgarr Date: Tue, 28 Jan 2025 21:31:54 +0100 Subject: [PATCH 4/8] add envs to github action pr hosting --- .github/workflows/firebase-hosting-pull-request.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 5e4e65d..8077dfe 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -6,6 +6,7 @@ permissions: pull-requests: write jobs: build_and_preview: + environment: preview if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} runs-on: ubuntu-latest steps: @@ -16,3 +17,11 @@ jobs: repoToken: ${{ secrets.GITHUB_TOKEN }} firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_DEV_COOKING }} projectId: dev-cooking + env: + VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }} + VITE_FIREBASE_AUTH_DOMAIN: ${{ vars.VITE_FIREBASE_AUTH_DOMAIN }} + VITE_FIREBASE_PROJECT_ID: ${{ vars.VITE_FIREBASE_PROJECT_ID }} + VITE_FIREBASE_STORAGE_BUCKET: ${{ vars.VITE_FIREBASE_STORAGE_BUCKET }} + VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ vars.VITE_FIREBASE_MESSAGING_SENDER_ID }} + VITE_FIREBASE_APP_ID: ${{ vars.VITE_FIREBASE_APP_ID }} + VITE_FIREBASE_DATABASE_URL: ${{ vars.VITE_FIREBASE_DATABASE_URL }} From c5b39141256a8e1f61c0f9ed35dfd60dc97740c6 Mon Sep 17 00:00:00 2001 From: pgarr Date: Tue, 28 Jan 2025 21:59:01 +0100 Subject: [PATCH 5/8] test env variables --- .github/workflows/firebase-hosting-pull-request.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 8077dfe..51166b7 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -11,12 +11,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: npm ci && npm run build + - run: | + echo "VITE_FIREBASE_DATABASE_URL : $VITE_FIREBASE_DATABASE_URL" + # - run: npm ci && npm run build - uses: FirebaseExtended/action-hosting-deploy@v0 - with: - repoToken: ${{ secrets.GITHUB_TOKEN }} - firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_DEV_COOKING }} - projectId: dev-cooking env: VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }} VITE_FIREBASE_AUTH_DOMAIN: ${{ vars.VITE_FIREBASE_AUTH_DOMAIN }} @@ -25,3 +23,8 @@ jobs: VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ vars.VITE_FIREBASE_MESSAGING_SENDER_ID }} VITE_FIREBASE_APP_ID: ${{ vars.VITE_FIREBASE_APP_ID }} VITE_FIREBASE_DATABASE_URL: ${{ vars.VITE_FIREBASE_DATABASE_URL }} + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_DEV_COOKING }} + projectId: dev-cooking + From c86848d5db13329b59ad17f65cefe7d502ecb960 Mon Sep 17 00:00:00 2001 From: pgarr Date: Tue, 28 Jan 2025 22:02:23 +0100 Subject: [PATCH 6/8] try build --- .github/workflows/firebase-hosting-pull-request.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 51166b7..79490df 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -11,9 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: | - echo "VITE_FIREBASE_DATABASE_URL : $VITE_FIREBASE_DATABASE_URL" - # - run: npm ci && npm run build + - run: npm ci && npm run build - uses: FirebaseExtended/action-hosting-deploy@v0 env: VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }} From 60f168f9d401520a1c1cd0ed0ce1787a79c06a49 Mon Sep 17 00:00:00 2001 From: pgarr Date: Tue, 28 Jan 2025 22:08:55 +0100 Subject: [PATCH 7/8] fix preview --- .../firebase-hosting-pull-request.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 79490df..763fca4 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -9,18 +9,18 @@ jobs: environment: preview if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} runs-on: ubuntu-latest + env: + VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }} + VITE_FIREBASE_AUTH_DOMAIN: ${{ vars.VITE_FIREBASE_AUTH_DOMAIN }} + VITE_FIREBASE_PROJECT_ID: ${{ vars.VITE_FIREBASE_PROJECT_ID }} + VITE_FIREBASE_STORAGE_BUCKET: ${{ vars.VITE_FIREBASE_STORAGE_BUCKET }} + VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ vars.VITE_FIREBASE_MESSAGING_SENDER_ID }} + VITE_FIREBASE_APP_ID: ${{ vars.VITE_FIREBASE_APP_ID }} + VITE_FIREBASE_DATABASE_URL: ${{ vars.VITE_FIREBASE_DATABASE_URL }} steps: - uses: actions/checkout@v4 - run: npm ci && npm run build - - uses: FirebaseExtended/action-hosting-deploy@v0 - env: - VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }} - VITE_FIREBASE_AUTH_DOMAIN: ${{ vars.VITE_FIREBASE_AUTH_DOMAIN }} - VITE_FIREBASE_PROJECT_ID: ${{ vars.VITE_FIREBASE_PROJECT_ID }} - VITE_FIREBASE_STORAGE_BUCKET: ${{ vars.VITE_FIREBASE_STORAGE_BUCKET }} - VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ vars.VITE_FIREBASE_MESSAGING_SENDER_ID }} - VITE_FIREBASE_APP_ID: ${{ vars.VITE_FIREBASE_APP_ID }} - VITE_FIREBASE_DATABASE_URL: ${{ vars.VITE_FIREBASE_DATABASE_URL }} + - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: ${{ secrets.GITHUB_TOKEN }} firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_DEV_COOKING }} From 2e3ea4388fe3c2cda7814f30ddc829e7f0f73f58 Mon Sep 17 00:00:00 2001 From: pgarr Date: Thu, 30 Jan 2025 19:30:13 +0100 Subject: [PATCH 8/8] fix production workflow --- .github/workflows/firebase-hosting-merge.yml | 11 ++++++++++- .../firebase-hosting-pull-request.yml | 19 +++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index 18b8811..735f218 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -5,7 +5,16 @@ on: - main jobs: build_and_deploy: + environment: production runs-on: ubuntu-latest + env: + VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }} + VITE_FIREBASE_AUTH_DOMAIN: ${{ vars.VITE_FIREBASE_AUTH_DOMAIN }} + VITE_FIREBASE_PROJECT_ID: ${{ vars.VITE_FIREBASE_PROJECT_ID }} + VITE_FIREBASE_STORAGE_BUCKET: ${{ vars.VITE_FIREBASE_STORAGE_BUCKET }} + VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ vars.VITE_FIREBASE_MESSAGING_SENDER_ID }} + VITE_FIREBASE_APP_ID: ${{ vars.VITE_FIREBASE_APP_ID }} + VITE_FIREBASE_DATABASE_URL: ${{ vars.VITE_FIREBASE_DATABASE_URL }} steps: - uses: actions/checkout@v4 - run: npm ci && npm run build @@ -14,4 +23,4 @@ jobs: repoToken: ${{ secrets.GITHUB_TOKEN }} firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_DEV_COOKING }} channelId: live - projectId: dev-cooking + projectId: ${{ vars.VITE_FIREBASE_PROJECT_ID }} diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 763fca4..007b071 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -10,19 +10,18 @@ jobs: if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} runs-on: ubuntu-latest env: - VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }} - VITE_FIREBASE_AUTH_DOMAIN: ${{ vars.VITE_FIREBASE_AUTH_DOMAIN }} - VITE_FIREBASE_PROJECT_ID: ${{ vars.VITE_FIREBASE_PROJECT_ID }} - VITE_FIREBASE_STORAGE_BUCKET: ${{ vars.VITE_FIREBASE_STORAGE_BUCKET }} - VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ vars.VITE_FIREBASE_MESSAGING_SENDER_ID }} - VITE_FIREBASE_APP_ID: ${{ vars.VITE_FIREBASE_APP_ID }} - VITE_FIREBASE_DATABASE_URL: ${{ vars.VITE_FIREBASE_DATABASE_URL }} + VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }} + VITE_FIREBASE_AUTH_DOMAIN: ${{ vars.VITE_FIREBASE_AUTH_DOMAIN }} + VITE_FIREBASE_PROJECT_ID: ${{ vars.VITE_FIREBASE_PROJECT_ID }} + VITE_FIREBASE_STORAGE_BUCKET: ${{ vars.VITE_FIREBASE_STORAGE_BUCKET }} + VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ vars.VITE_FIREBASE_MESSAGING_SENDER_ID }} + VITE_FIREBASE_APP_ID: ${{ vars.VITE_FIREBASE_APP_ID }} + VITE_FIREBASE_DATABASE_URL: ${{ vars.VITE_FIREBASE_DATABASE_URL }} steps: - uses: actions/checkout@v4 - run: npm ci && npm run build - - uses: FirebaseExtended/action-hosting-deploy@v0 + - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: ${{ secrets.GITHUB_TOKEN }} firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_DEV_COOKING }} - projectId: dev-cooking - + projectId: ${{ vars.VITE_FIREBASE_PROJECT_ID }}