Skip to content

Commit abdbc7b

Browse files
authored
Merge pull request #4 from pgarr/init-firebase-deplloy
Init firebase deplloy
2 parents 9b1b940 + 2e3ea43 commit abdbc7b

7 files changed

Lines changed: 61 additions & 73 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Deploy to Firebase Hosting on merge
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
build_and_deploy:
8+
environment: production
9+
runs-on: ubuntu-latest
10+
env:
11+
VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }}
12+
VITE_FIREBASE_AUTH_DOMAIN: ${{ vars.VITE_FIREBASE_AUTH_DOMAIN }}
13+
VITE_FIREBASE_PROJECT_ID: ${{ vars.VITE_FIREBASE_PROJECT_ID }}
14+
VITE_FIREBASE_STORAGE_BUCKET: ${{ vars.VITE_FIREBASE_STORAGE_BUCKET }}
15+
VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ vars.VITE_FIREBASE_MESSAGING_SENDER_ID }}
16+
VITE_FIREBASE_APP_ID: ${{ vars.VITE_FIREBASE_APP_ID }}
17+
VITE_FIREBASE_DATABASE_URL: ${{ vars.VITE_FIREBASE_DATABASE_URL }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
- run: npm ci && npm run build
21+
- uses: FirebaseExtended/action-hosting-deploy@v0
22+
with:
23+
repoToken: ${{ secrets.GITHUB_TOKEN }}
24+
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_DEV_COOKING }}
25+
channelId: live
26+
projectId: ${{ vars.VITE_FIREBASE_PROJECT_ID }}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Deploy to Firebase Hosting on PR
2+
on: pull_request
3+
permissions:
4+
checks: write
5+
contents: read
6+
pull-requests: write
7+
jobs:
8+
build_and_preview:
9+
environment: preview
10+
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
11+
runs-on: ubuntu-latest
12+
env:
13+
VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }}
14+
VITE_FIREBASE_AUTH_DOMAIN: ${{ vars.VITE_FIREBASE_AUTH_DOMAIN }}
15+
VITE_FIREBASE_PROJECT_ID: ${{ vars.VITE_FIREBASE_PROJECT_ID }}
16+
VITE_FIREBASE_STORAGE_BUCKET: ${{ vars.VITE_FIREBASE_STORAGE_BUCKET }}
17+
VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ vars.VITE_FIREBASE_MESSAGING_SENDER_ID }}
18+
VITE_FIREBASE_APP_ID: ${{ vars.VITE_FIREBASE_APP_ID }}
19+
VITE_FIREBASE_DATABASE_URL: ${{ vars.VITE_FIREBASE_DATABASE_URL }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
- run: npm ci && npm run build
23+
- uses: FirebaseExtended/action-hosting-deploy@v0
24+
with:
25+
repoToken: ${{ secrets.GITHUB_TOKEN }}
26+
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_DEV_COOKING }}
27+
projectId: ${{ vars.VITE_FIREBASE_PROJECT_ID }}
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: CI
22

33
on:
4-
push:
5-
branches: ["main"]
64
pull_request:
75
branches: ["main"]
86

@@ -23,4 +21,3 @@ jobs:
2321
- run: npm ci
2422
- run: npm run lint
2523
- run: npm test
26-
- run: npm run build --if-present

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
/.firebase
1313
.firebaserc
14+
firebase-debug.log
1415
database.rules.json
1516

1617
sample-data.json

README.md

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +0,0 @@
1-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2-
3-
## Available Scripts
4-
5-
In the project directory, you can run:
6-
7-
### `npm start`
8-
9-
Runs the app in the development mode.<br />
10-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11-
12-
The page will reload if you make edits.<br />
13-
You will also see any lint errors in the console.
14-
15-
### `npm test`
16-
17-
Launches the test runner in the interactive watch mode.<br />
18-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19-
20-
### `npm run build`
21-
22-
Builds the app for production to the `build` folder.<br />
23-
It correctly bundles React in production mode and optimizes the build for the best performance.
24-
25-
The build is minified and the filenames include the hashes.<br />
26-
Your app is ready to be deployed!
27-
28-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29-
30-
### `npm run eject`
31-
32-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33-
34-
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.
35-
36-
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.
37-
38-
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.
39-
40-
## Learn More
41-
42-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43-
44-
To learn React, check out the [React documentation](https://reactjs.org/).
45-
46-
### Code Splitting
47-
48-
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49-
50-
### Analyzing the Bundle Size
51-
52-
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53-
54-
### Making a Progressive Web App
55-
56-
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57-
58-
### Advanced Configuration
59-
60-
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61-
62-
### Deployment
63-
64-
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65-
66-
### `npm run build` fails to minify
67-
68-
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

firebase.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
"rules": "database.rules.json"
44
},
55
"hosting": {
6-
"public": "build",
6+
"public": "dist",
7+
"ignore": [
8+
"firebase.json",
9+
"**/.*",
10+
"**/node_modules/**"
11+
],
712
"rewrites": [
813
{
914
"source": "**",

src/components/Recipes/RecipesDetails/RecipeDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const RecipeDetails = () => {
88
const recipes = useAppSelector((state) => state.recipes.recipes);
99
const loading = useAppSelector((state) => state.recipes.loading);
1010
const params = useParams();
11-
const id = Number(params.id) || -1;
11+
const id = Number(params.id);
1212
const selectedRecipe = recipes.find((recipe) => recipe.id === id);
1313

1414
return (

0 commit comments

Comments
 (0)