Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
GalvinGao committed Apr 29, 2022
2 parents d141733 + 99b480e commit 1f7d252
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 28 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build Docker Image

on:
push:
# trigger on version tag push
tags:
- "v*"

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

# - name: Run Snyk to check for vulnerabilities
# uses: snyk/actions/golang@master
# continue-on-error: true
# env:
# SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
# with:
# args: --sarif-file-output=snyk.sarif

# - name: Upload result to GitHub Code Scanning
# uses: github/codeql-action/upload-sarif@v1
# with:
# sarif_file: snyk.sarif

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get Tag Version
id: get_version
run: |
export TRUNCATED_GITHUB_SHA=$(echo ${{ github.sha }} | cut -c1-7);
echo "TRUNCATED_GITHUB_SHA=${TRUNCATED_GITHUB_SHA}" >> $GITHUB_ENV
echo "GIT_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
# if `alpha` or `beta` is in the tag, then it will be a pre-release
if [[ ${GITHUB_REF} == *"alpha"* ]] || [[ ${GITHUB_REF} == *"beta"* ]]; then
echo "PRE_RELEASE=true" >> $GITHUB_ENV
fi
- name: Build and Publish to Registry
uses: docker/build-push-action@v2
with:
push: true
tags: |
ghcr.io/penguin-statistics/frontend-v2:latest,
ghcr.io/penguin-statistics/frontend-v2:${{ env.GIT_TAG }}
secret-files: |
PENGUIN_RECOGNITION_SUBMITTER_JS=/run/secrets/PENGUIN_RECOGNITION_SUBMITTER_JS
- name: Create GitHub Release
uses: marvinpinto/action-automatic-releases@v1.2.1
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: ${{ env.PRE_RELEASE }}
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ COPY yarn.lock .
# Setup yarn
RUN yarn install

# Build the app
RUN yarn build:web
COPY . .

RUN --mount=type=secret,id=PENGUIN_RECOGNITION_SUBMITTER_JS,target=/app/src/utils/vendors/recognitionSubmitter.js \
yarn build:web

# runner
FROM nginx:stable AS runner

COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80

CMD ["nginx" "-g" "daemon off;"]
CMD ["nginx", "-g", "daemon off;"]
50 changes: 25 additions & 25 deletions src/injections/sentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import environment from "@/utils/environment";
import Vue from "vue";
import router from "@/router";

const sentEvents = {};
// const sentEvents = {};

// set the limitation of a same client sending the same message event to Sentry for every session
const maxSameEventPerClient = 10;
// const maxSameEventPerClient = 10;

if (environment.production) {
Sentry.init({
Expand Down Expand Up @@ -86,30 +86,30 @@ if (environment.production) {
/webappstoolbarba\.texthelp\.com\//i,
/metrics\.itunes\.apple\.com\.edgesuite\.net\//i,
],
beforeSend(event) {
if (!environment.production) {
console.log("Sentry: non-production, dropping sentry event", event);
return null;
}
// beforeSend(event) {
// if (!environment.production) {
// console.log("Sentry: non-production, dropping sentry event", event);
// return null;
// }

const { message } = event;
if (message in sentEvents) {
const counts = sentEvents[message];
// const { message } = event;
// if (message in sentEvents) {
// const counts = sentEvents[message];

// if there's still 'quota' for the client to send this event
if (counts < maxSameEventPerClient) {
// record that we have send the event this time
sentEvents[message] = counts + 1;
// report event
return event;
} else {
console.log("Sentry: ignored event, already sent", event);
}
} else {
// this has not yet been sent; init var and send it
sentEvents[message] = 1;
return event;
}
},
// // if there's still 'quota' for the client to send this event
// if (counts < maxSameEventPerClient) {
// // record that we have send the event this time
// sentEvents[message] = counts + 1;
// // report event
// return event;
// } else {
// console.log("Sentry: ignored event, already sent", event);
// }
// } else {
// // this has not yet been sent; init var and send it
// sentEvents[message] = 1;
// return event;
// }
// },
});
}

0 comments on commit 1f7d252

Please sign in to comment.