Open carlosmfreitas2409 opened 1 week ago
I resolved an issue related to package installation in the CI/CD pipeline. Here's how:
Avoid committing .npmrc
Remove or avoid committing the .npmrc
file. For reasons I couldn't fully determine, having .npmrc
with bunfig.toml
in the repository caused configuration issues on the CI/CD side.
Commit a custom bunfig.toml
file
To enable local package installation, create and commit a bunfig.toml
file with the following content and commit it:
[install.scopes]
'@my-org' = { token = "$BUN_AUTH_TOKEN", url = "https://npm.pkg.github.com" }
Set up a .env
file for local development
Ensure you have a .env
file locally to define the BUN_AUTH_TOKEN
for authentication:
BUN_AUTH_TOKEN=******
Update your CI/CD workflow
Use the following configuration in your GitHub Actions workflow to install dependencies:
- name: Install Bun
uses: oven-sh/setup-bun@v2
- name: Install Dependencies
run: bun install --frozen-lockfile
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Optional
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Optional
BUN_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
We should probably create some sort of merge mechanic like in https://github.com/oven-sh/setup-bun/pull/39
Hi @carlosmfreitas2409 and @Yurchishin, could you please test my PR fixing this issue? I think oven-sh/setup-bun@feat/multiple-registries
or oven-sh/setup-bun@7ac6e6faeade3b75e9bff88d66e9200170e311cd
should work :)
Hi @Yurchishin and @xhyrom
First of all, thanks for the answers guys!
To update you guys. I didn't have any bunfig.toml
in my repository, however, in the workflow I'm using setup-bun
, there's another step later (changesets) that needs to update some files in the repository and then pushes those changes, creating a new pull request.
Since the Bun action creates the bunfig.toml
file, the later step was committing the config file to the PR (and I merged).
So the first time, when bunfig.toml
hadn't been merged, the install step worked without any problems.
And after merged, the install step started giving the redefine key
error.
Even though I was committing the file that is being created from the action, I think this should not happen, right? (I could be wrong)
Because theoretically, if I create the file manually, it will have the same content/code that the action created and the same error would happen again (I haven't tested this).
So the temporary solution I had was to delete the bunfig.toml
file after the install deps step and it works fine.
I will test if your PR resolves it in a few hours @xhyrom, thank you so much!
Thanks, I wonder that we should probably also handle this case by removing the bunfig at the end / reverthing the content of the file 🤔
Yes, I believe it would be important. However, it would not solve all cases (including this one).
Let's suppose that I wanted to publish a lib on the Github Registry and for that I need to use the registry-url
. I will need bunfig.toml
until the publish script runs.
registry-url
)registry-url
)In the above step, it will work.
However, if between these steps we are using something that commits, bunfig will still be committed because the post-setup will not have been run yet. Example:
registry-url
)registry-url
)Maybe, instead of writing the bunfig file with process.cwd
, there is some way to create it in temporarily directory? I think Github provide a RUNNER_TEMP
and HOME
env.
(I think this also refers to #99)
Ohh, yes, you're right about this one, I'll see what we can do.
A question not related to this project but Bun: shouldn't Bun have a environment variable for registry auth like npm has?
A question not related to this project but Bun: shouldn't Bun have a environment variable for registry auth like npm has?
As you said, this is not related to setup-bun. Create an issue on oven-sh/bun or ask on discord server :)
Hello!
I have the following step (exactly as it says in the README):
And when running the workflow, the following error occurs:
The
bunfig.toml
was created automatically by the action and looks like this:There is an issue with this problem (#33), but it is closed and without a solution.