Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Failed to replace env in config: ${NPM_TOKEN}" after release #2

Closed
filipesilva opened this issue Oct 25, 2019 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@filipesilva
Copy link

Describe the bug
Heya, if I try to use a yarn create command after the release action goes through, I get the following error:

Run yarn create cljs-app my-cljs-app
yarn create v1.19.0
error An unexpected error occurred: "Failed to replace env in config: ${NPM_TOKEN}".
info If you think this is a bug, please open a bug report with the information provided in "/home/runner/work/create-cljs-app/create-cljs-app/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.
##[error]Process completed with exit code 1.

To Reproduce
Steps to reproduce the behavior:
My workflow looks like this: https://github.com/filipesilva/create-cljs-app/blob/c4461fdc07b9a92141fc3ae1fab9db783b5665be/.github/workflows/nodejs.yml#L37-L62

  release:
    if: github.ref == 'refs/heads/master' && github.repository == 'filipesilva/create-cljs-app'
    needs: test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Download Artifact
      uses: actions/download-artifact@master
      with:
        name: dist  
    - name: Semantic Release
      uses: cycjimmy/semantic-release-action@v2
      id: semantic
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
    # Test the release if one was made.
    # Would be nice to group these steps on the `if` conditional, but no way to do it yet.
    - name: Use Node.js 12.x
      if: steps.semantic.outputs.new_release_published == 'true'
      uses: actions/setup-node@v1
      with:
        node-version: '12.x'
    - name: Try to use release
      if: steps.semantic.outputs.new_release_published == 'true'
      run: yarn create cljs-app my-cljs-app

I get the error in the Try to use release step. You can see an failing run in https://github.com/filipesilva/create-cljs-app/runs/275024115.

Expected behavior
I expected no error. I suppose it happens because semantic-release-action writes to the .npmrc file? But I don't understand why the variable that I had to set as a secret doesn't work anymore.

Additional context
Add any other context about the problem here.

@cycjimmy
Copy link
Owner

cycjimmy commented Oct 26, 2019

semantic-release-action does not have extra operations on .npmrc file.

I also got this problem that occurs whether I use this action library or use the npx semantic-release command directly in Github Actions.
I recommend temporarily using the plugin of @semantic-release/exec to complete your follow-up tasks.

semantic-release configuration:

"plugins": [
  "@semantic-release/commit-analyzer",
  "@semantic-release/release-notes-generator",
  ["@semantic-release/exec", {
    "successCmd": "your code here"
  }],
  "@semantic-release/npm",
  "@semantic-release/github"
]

workflow file:

uses: cycjimmy/semantic-release-action@v2
id: semantic
with:
  extra_plugins: |
    @semantic-release/exec
env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

@cycjimmy cycjimmy added the bug Something isn't working label Oct 26, 2019
cycjimmy added a commit that referenced this issue Oct 26, 2019
Issue: "Failed to replace env in config: ${NPM_TOKEN}" after release #2
solution:semantic-release/semantic-release#974 (comment)
github-actions bot pushed a commit that referenced this issue Oct 26, 2019
## [2.0.1](v2.0.0...v2.0.1) (2019-10-26)

### Bug Fixes

* **.npmrc:** clean up `.npmrc` file in the repo after releasing ([a0ef86e](a0ef86e)), closes [#2](#2) [/github.com/semantic-release/semantic-release/issues/974#issuecomment-546577677](https://github.com//github.com/semantic-release/semantic-release/issues/974/issues/issuecomment-546577677)
@cycjimmy
Copy link
Owner

@filipesilva
I have fixed the unexpected error (v2.0.1, v2.0.2). You don't have to change your workflow file, just re-run it to fix your problem.

@filipesilva
Copy link
Author

That's great, thank you!

cycjimmy pushed a commit that referenced this issue Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants