|
| 1 | +name: New Sentry Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: |
| 9 | + id-token: write # This is required for requesting the JWT |
| 10 | + contents: read # This is required for actions/checkout |
| 11 | + |
| 12 | +jobs: |
| 13 | + release: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + env: |
| 16 | + SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} |
| 17 | + SENTRY_DEPLOY_ENVIRONMENT: ${{ secrets.SENTRY_DEPLOY_ENVIRONMENT }} |
| 18 | + # Specifies custom Sentry Endpoint to send release information to |
| 19 | + # Defaults to https://sentry.io |
| 20 | + SENTRY_URL: ${{ secrets.SENTRY_URL }} |
| 21 | + # The organization name for the org that we want to send release info to |
| 22 | + SENTRY_ORG_ID: ${{ secrets.SENTRY_ORG_ID }} |
| 23 | + |
| 24 | + steps: |
| 25 | + |
| 26 | + |
| 27 | + - name: Install OIDC Client from Core Package |
| 28 | + run: npm install @actions/[email protected] @actions/http-client |
| 29 | + |
| 30 | + - name: Get Id Token |
| 31 | + uses: actions/github-script@v6 |
| 32 | + id: idtoken |
| 33 | + env: |
| 34 | + SENTRY_URL: ${{ secrets.SENTRY_URL }} |
| 35 | + with: |
| 36 | + script: | |
| 37 | + const actions_core = require('@actions/core') |
| 38 | + let id_token = await actions_core.getIDToken(process.env.SENTRY_URL) |
| 39 | + actions_core.setOutput('token', id_token) |
| 40 | +
|
| 41 | + - name: Create new Sentry release and deploy to Heroku |
| 42 | + shell: bash |
| 43 | + env: |
| 44 | + SENTRY_URL: ${{ secrets.SENTRY_URL }} |
| 45 | + SENTRY_ORG_ID: ${{ secrets.SENTRY_ORG_ID }} |
| 46 | + GITHUB_OIDC_TOKEN: ${{ steps.idtoken.outputs.token }} |
| 47 | + run: | |
| 48 | + # Install Sentry CLI |
| 49 | + curl -sL https://sentry.io/get-cli/ | bash |
| 50 | + |
| 51 | + # Get the Auth Token from Sentry's API Endpoint |
| 52 | + sentry_access_token=`curl -X POST "$SENTRY_URL/oauth/token/" -H 'Accept-Encoding: gzip, deflate, br, zstd' \ |
| 53 | + -H 'Content-Type: application/json; charset=utf-8' -H 'Accept: application/json' \ |
| 54 | + -d "{ |
| 55 | + \"grant_type\": \"urn:ietf:params:oauth:grant-type:token-exchange\", |
| 56 | + \"resource\": \"$SENTRY_URL/api/0/organizations/$SENTRY_ORG_ID\", |
| 57 | + \"subject_token\": \"$GITHUB_OIDC_TOKEN\", |
| 58 | + \"subject_token_type\": \"urn:ietf:params:oauth:token-type:id_token\" |
| 59 | + }" | jq -r '.access_token'` |
| 60 | +
|
| 61 | + # Expose the scoped auth token se for release API |
| 62 | + export SENTRY_AUTH_TOKEN=$sentry_access_token |
| 63 | + |
| 64 | + # Create new Sentry release |
| 65 | + export SENTRY_RELEASE=$(sentry-cli releases propose-version) |
| 66 | + sentry-cli releases new -p $SENTRY_PROJECT $SENTRY_RELEASE |
0 commit comments