Skip to content

Set SPECTRAL_DSN environment from JS instead of end-user workflow file#12

Merged
guylev008 merged 9 commits intoSpectralOps:mainfrom
chkp-jrosenboom:easier-env
Jun 14, 2023
Merged

Set SPECTRAL_DSN environment from JS instead of end-user workflow file#12
guylev008 merged 9 commits intoSpectralOps:mainfrom
chkp-jrosenboom:easier-env

Conversation

@chkp-jrosenboom
Copy link
Contributor

The action originally suggests that the user should first set SPECTRAL_DSN from GitHub Secrets, then pass this environment variable as an input to the action.

...
env:
  SPECTRAL_DSN: ${{ secrets.SPECTRAL_DSN }}
...
        uses: spectralops/spectral-github-action@v3
        with:
          spectral-dsn: ${{ env.SPECTRAL_DSN }}

If the user skips configuring the environment variable in their workflow file, and passes the input directly to the action, the installation will succeed because it uses the value read from inputs.spectral-dsn here.

The execution of the scan itself does not use the same value, and depends on SPECTRAL_DSN being set as an environment variable. Because of this, the scan fails in this scenario:

🙅‍ error: You need to provide your key (Spectral DSN).

This PR

  • changes the action to set SPECTRAL_DSN from the input variable in index.js
  • updates examples in README.md
  • updates example action

It removes the need for the user to provide SPECTRAL_DSN both as an input to the action and as an environment variable.

@chkp-jrosenboom
Copy link
Contributor Author

This PR requires a new tag 'v4' to be created after merging.
The examples will point to that tag already.

@guylev008 guylev008 merged commit ab90f8a into SpectralOps:main Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants