action-release icon indicating copy to clipboard operation
action-release copied to clipboard

Informing sentry about the latest release tag

Open altjx opened this issue 2 years ago • 1 comments

According to the documentation, it appears that it's possible to include the release tag when informing Sentry, but only if the PR is triggered via a release, is that correct?

In my case, I am creating a PR by another GitHub Workflow (not a release), and so I'm trying to determine a workaround with informing Sentry about the latest release tag version.

Here's what I have thus far:

  inform_sentry_about_release:
    runs-on: ubuntu-latest
    env:
      ACCESS_TOKEN: ${{ secrets.GH_PAT }}
    steps:
      - uses: actions/checkout@v2
      - name: Set GITHUB_VERSION variable
        run: |
          echo 'GITHUB_LATEST_RELEASE=$(curl -H "Authorization: token ${ACCESS_TOKEN}" "https://api.github.com/repos/myusername/myreponame/releases" -s | jq -r ".[0].tag_name")' >> $GITHUB_ENV
      - name: Create Sentry release
        uses: getsentry/action-release@v1
        env:
          SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
          SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
          SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
        with:
          environment: production
          version: ${{ GITHUB_LATEST_RELEASE }}

The problem is that the workflow fails here:

The workflow is not valid. .github/workflows/production-label.yml (Line: 131, Col: 20): Unrecognized named-value: 'GITHUB_LATEST_RELEASE'. Located at position 1 within expression: GITHUB_LATEST_RELEASE

which is referring to this:

version: ${{ GITHUB_LATEST_RELEASE }}

Is there a way to simply inform Sentry about the latest release tag without having to do all of this, or at least a way to utilize an environment variable that should be set from the previous step?

altjx avatar Dec 21 '22 13:12 altjx

Try accessing the created variable as ${{ env.GITHUB_LATEST_RELEASE }}. Notice the env. prefix

lewislbr avatar Sep 24 '23 13:09 lewislbr