diff --git a/.github/workflows/sentry.yml b/.github/workflows/sentry.yml new file mode 100644 index 00000000..712adebf --- /dev/null +++ b/.github/workflows/sentry.yml @@ -0,0 +1,33 @@ +name: sentryInit + +on: + push: + branches: + - master + workflow_dispatch: + inputs: + commit_hash: + description: 'The commit hash (or branch/tag) to build' + required: false + default: '' + +jobs: + createSentryRelease: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: ${{ github.event.inputs.commit_hash || 'refs/heads/master' }} + + - name: Install dependencies + run: npm ci + + - name: Build + env: + ENABLE_SENTRY: ${{ secrets.ENABLE_SENTRY }} + SENTRY_RELEASE: ${{ github.event.inputs.commit_hash && github.event.inputs.commit_hash }} + SENTRY_AUTH_TOKEN: ${{ github.event.inputs.commit_hash && secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG }} + SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} + run: npm run build --if-present diff --git a/fec.config.js b/fec.config.js index 5f9005c6..cbd3392f 100644 --- a/fec.config.js +++ b/fec.config.js @@ -55,26 +55,18 @@ if (process.env.NODE_ENV) { add_define('process.env.NODE_ENV', process.env.NODE_ENV); } -if (process.env.SENTRY_AUTH_TOKEN) { +if (process.env.ENABLE_SENTRY) { plugins.push( sentryWebpackPlugin({ - authToken: process.env.SENTRY_AUTH_TOKEN, - org: 'red-hat-it', - project: 'image-builder-rhel', - moduleMetadata: ({ release }) => ({ - dsn: 'https://f4b4288bbb7cf6c0b2ac1a2b90a076bf@o490301.ingest.us.sentry.io/4508297557901312', - release, + ...(process.env.SENTRY_AUTH_TOKEN && { + authToken: process.env.SENTRY_AUTH_TOKEN, }), - }) - ); -} else { - // justs injects the debug ids - plugins.push( - sentryWebpackPlugin({ org: 'red-hat-it', project: 'image-builder-rhel', moduleMetadata: ({ release }) => ({ dsn: 'https://f4b4288bbb7cf6c0b2ac1a2b90a076bf@o490301.ingest.us.sentry.io/4508297557901312', + org: 'red-hat-it', + project: 'image-builder-rhel', release, }), })