Skip to content

Commit

Permalink
Refactor firebase-hosting-merge.yml to include environment variables …
Browse files Browse the repository at this point in the history
…for Sentry and Firebase secrets
  • Loading branch information
sensasi-delight committed Oct 11, 2024
1 parent 321b5bf commit d1a709f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 39 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: npm ci && npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
env:
SENTRY_AUTH_TOKEN: '${{ secrets.SENTRY_AUTH_TOKEN }}'
FIREBASE_API_KEY: '${{ secrets.FIREBASE_API_KEY }}'
FIREBASE_APP_ID: '${{ secrets.FIREBASE_APP_ID }}'
FIREBASE_AUTH_DOMAIN: '${{ secrets.FIREBASE_AUTH_DOMAIN }}'
FIREBASE_MEASUREMENT_ID: '${{ secrets.FIREBASE_MEASUREMENT_ID }}'
FIREBASE_MESSAGING_SENDER_ID: '${{ secrets.FIREBASE_MESSAGING_SENDER_ID }}'
FIREBASE_PROJECT_ID: '${{ secrets.FIREBASE_PROJECT_ID }}'
FIREBASE_STORAGE_BUCKET: '${{ secrets.FIREBASE_STORAGE_BUCKET }}'
VITE_SENTRY_AUTH_TOKEN: '${{ secrets.SENTRY_AUTH_TOKEN }}'
VITE_FIREBASE_API_KEY: '${{ secrets.FIREBASE_API_KEY }}'
VITE_FIREBASE_APP_ID: '${{ secrets.FIREBASE_APP_ID }}'
VITE_FIREBASE_AUTH_DOMAIN: '${{ secrets.FIREBASE_AUTH_DOMAIN }}'
VITE_FIREBASE_MEASUREMENT_ID: '${{ secrets.FIREBASE_MEASUREMENT_ID }}'
VITE_FIREBASE_MESSAGING_SENDER_ID: '${{ secrets.FIREBASE_MESSAGING_SENDER_ID }}'
VITE_FIREBASE_PROJECT_ID: '${{ secrets.FIREBASE_PROJECT_ID }}'
VITE_FIREBASE_STORAGE_BUCKET: '${{ secrets.FIREBASE_STORAGE_BUCKET }}'
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_SIMULASI_GRADING_SAWIT }}'
Expand Down
7 changes: 4 additions & 3 deletions src/components/feedback-dialog/feedback-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
HowToVote as HowToVoteIcon,
Send as SendIcon,
} from '@mui/icons-material'
import { captureFeedback, captureMessage } from '@sentry/browser'
import * as sentry from '@sentry/browser'

export function FeedbackDialog() {
const [open, setOpen] = useState(false)
Expand Down Expand Up @@ -64,11 +64,12 @@ export function FeedbackDialog() {
return
}

captureFeedback({
sentry.captureFeedback({
name: formValues.name,
email: formValues.email,
message: formValues.message,
associatedEventId: captureMessage('Feedback'),
associatedEventId:
sentry.captureMessage('Feedback'),
})

setOpen(false)
Expand Down
16 changes: 8 additions & 8 deletions src/providers/components/firebase-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import packageJson from '../../../package.json'
*
* production conf is setted in https://github.com/sensasi-delight/simulasi-grading-sawit/settings/environments
*/
const FIREBASE_APP = import.meta.env.FIREBASE_PROJECT_ID
const FIREBASE_APP = import.meta.env.PROD
? initializeApp({
apiKey: import.meta.env.FIREBASE_API_KEY,
authDomain: import.meta.env.FIREBASE_AUTH_DOMAIN,
projectId: import.meta.env.FIREBASE_PROJECT_ID,
storageBucket: import.meta.env.FIREBASE_STORAGE_BUCKET,
messagingSenderId: import.meta.env.FIREBASE_MESSAGING_SENDER_ID,
appId: import.meta.env.FIREBASE_APP_ID,
measurementId: import.meta.env.FIREBASE_MEASUREMENT_ID,
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_FIREBASE_APP_ID,
measurementId: import.meta.env.VITE_FIREBASE_MEASUREMENT_ID,
})
: null

Expand Down
43 changes: 24 additions & 19 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
import { defineConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import { sentryVitePlugin } from '@sentry/vite-plugin'
import { serwist } from '@serwist/vite'
import react from '@vitejs/plugin-react-swc'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
sentryVitePlugin({
org: 'sensasi-apps',
project: 'simulasi-grading-sawit',
}),
serwist({
swSrc: 'src/sw.ts',
swDest: 'sw.js',
globDirectory: 'dist',
injectionPoint: 'self.__SW_MANIFEST',
rollupFormat: 'iife',
}),
],
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())

build: {
sourcemap: true,
},
return {
plugins: [
react(),
sentryVitePlugin({
org: 'sensasi-apps',
project: 'simulasi-grading-sawit',
authToken: env.VITE_SENTRY_AUTH_TOKEN,
}),
serwist({
swSrc: 'src/sw.ts',
swDest: 'sw.js',
globDirectory: 'dist',
injectionPoint: 'self.__SW_MANIFEST',
rollupFormat: 'iife',
}),
],

build: {
sourcemap: true,
},
}
})

0 comments on commit d1a709f

Please sign in to comment.