-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88df683
commit e346919
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: New Sentry Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
id-token: write # This is required for requesting the JWT | ||
contents: read # This is required for actions/checkout | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
env: | ||
##SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | ||
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | ||
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | ||
SENTRY_DEPLOY_ENVIRONMENT: ${{ secrets.SENTRY_DEPLOY_ENVIRONMENT }} | ||
# Specifies custom Sentry Endpoint to send release information to | ||
# Defaults to https://sentry.io | ||
SENTRY_URL: ${{ secrets.SENTRY_URL }} | ||
# The organization name for the org that we want to send release info to | ||
SENTRY_ORG_SLUG: ${{ secrets.SENTRY_ORG_SLUG }} | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- name: Install OIDC Client from Core Package | ||
run: npm install @actions/[email protected] @actions/http-client | ||
|
||
- name: Get Id Token | ||
uses: actions/github-script@v6 | ||
id: idtoken | ||
with: | ||
script: | | ||
const actions_core = require('@actions/core') | ||
let id_token = await actions_core.getIDToken('http://trosentry.ngrok.dev') | ||
actions_core.setOutput('token', id_token) | ||
- name: Create new Sentry release and deploy to Heroku | ||
shell: bash | ||
env: | ||
GITHUB_OIDC_TOKEN: ${{ steps.idtoken.outputs.token }} | ||
run: | | ||
# Install Sentry CLI | ||
curl -sL https://sentry.io/get-cli/ | bash | ||
# Get the Auth Token from Sentry's API Endpoint | ||
curl -X POST "https://trosentry.ngrok.dev/oauth/token/" -H 'Accept-Encoding: gzip, deflate, br, zstd' \ | ||
-H 'Content-Type: application/json; charset=utf-8' -H 'Accept: application/json' \ | ||
-d "{ | ||
\"grant_type\": \"urn:ietf:params:oauth:grant-type:token-exchange\", | ||
\"resource\": \"https://trosentry.ngrok.dev/api/0/organizations/2\", | ||
\"subject_token\": \"$GITHUB_OIDC_TOKEN\", | ||
\"subject_token_type\": \"urn:ietf:params:oauth:token-type:id_token\" | ||
}" | ||
# Expose the scoped auth token to use for release API | ||
export SENTRY_AUTH_TOKEN=$sentry_access_token | ||
# Create new Sentry release | ||
export SENTRY_RELEASE=$(sentry-cli releases propose-version) | ||
sentry-cli releases new -p $SENTRY_PROJECT $SENTRY_RELEASE | ||
sentry-cli releases set-commits --auto $SENTRY_RELEASE | ||
sentry-cli releases finalize $SENTRY_RELEASE | ||
# Create new deploy for this Sentry release | ||
sentry-cli releases deploys $SENTRY_RELEASE new -e $SENTRY_DEPLOY_ENVIRONMENT |