Skip to content

Instantly share code, notes, and snippets.

@yusufkandemir
Last active March 11, 2024 10:53
Show Gist options
  • Save yusufkandemir/e0e3e38231ecebe7a376484815399758 to your computer and use it in GitHub Desktop.
Save yusufkandemir/e0e3e38231ecebe7a376484815399758 to your computer and use it in GitHub Desktop.
Github Actions: Deploy a Quasar Framework app to Firebase Hosting and create a Sentry release
# .github/workflows/hosting.yml
name: Hosting
on:
# You can use other strategies here, check: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
push:
branches:
- production
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Node (10)
uses: actions/setup-node@v1
with:
node-version: 10.x
- name: Install Sentry CLI
run: curl -sL https://sentry.io/get-cli/ | bash
- name: Propose a Sentry Release
run: echo "SENTRY_RELEASE=$(sentry-cli releases propose-version)" > $GITHUB_ENV
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Build PWA
run: npx quasar build -m pwa --publish sentry
- name: Create a Sentry Release
run: |
sentry-cli releases new -p $SENTRY_PROJECT $SENTRY_RELEASE
sentry-cli releases set-commits --auto $SENTRY_RELEASE
sentry-cli releases files $SENTRY_RELEASE upload-sourcemaps ./dist/pwa --rewrite --strip-common-prefix
sentry-cli releases finalize $SENTRY_RELEASE
# Create new deploy for this Sentry release
sentry-cli releases deploys $SENTRY_RELEASE new -e $SENTRY_DEPLOY_ENVIRONMENT
env:
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_DEPLOY_ENVIRONMENT: "production"
- name: Remove Source Maps
run: |
# Remove all source maps
find ./dist/pwa -regextype posix-extended -regex '.*.(js|css).map$' -type f -delete
# Remove source map references in files
sed -i 's/^\/\/# sourceMappingURL=.*$//' $(find ./dist/pwa -regextype posix-extended -regex '.*.(js|css)$' -type f)
- name: Upload Build Artifacts
uses: actions/upload-artifact@v2
with:
name: build-artifacts
path: "./dist/pwa"
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Download Build Artifacts
uses: actions/download-artifact@v2
with:
name: build-artifacts
path: "./dist/pwa"
- name: Deploy to Firebase
uses: w9jds/firebase-action@v1.5.0
with:
args: deploy --only hosting
env:
PROJECT_ID: "YOUR-FIREBASE-PROJECT-ID-HERE"
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
// ...
boot: [
'sentry'
],
// ...
build: {
// Generated when on development, debug flag is passed (preserving the old behavior) or `--publish sentry` is set:
// quasar build -m pwa --publish sentry
sourceMap: ctx.dev || ctx.debug || ctx.publish === 'sentry',
env: {
SENTRY_RELEASE: process.env.SENTRY_RELEASE // @quasar/app v2.x
// SENTRY_RELEASE: JSON.stringify(process.env.SENTRY_RELEASE) // @quasar/app v1.x
}
// ...
}
//...
// /boot/sentry.js
import { boot } from 'quasar/wrappers'
import * as Sentry from '@sentry/browser'
import * as Integrations from '@sentry/integrations'
export default boot(({ Vue }) => {
Sentry.init({
dsn: 'YOUR_DSN_HERE',
release: process.env.SENTRY_RELEASE,
integrations: [
new Integrations.Vue({ Vue, attachProps: true }),
new Integrations.RewriteFrames({
iteratee (frame) {
// Strip out the query part (which contains `?__WB_REVISION__=**`)
frame.abs_path = frame.abs_path.split('?')[0]
return frame
}
})
]
})
})
@mitchba98
Copy link

Thanks, saved me hours of debugging 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment