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

Consolidate NuGet package tokens #83

Merged
merged 1 commit into from
Oct 1, 2024
Merged

Consolidate NuGet package tokens #83

merged 1 commit into from
Oct 1, 2024

Conversation

spikeheap
Copy link
Contributor

@spikeheap spikeheap commented Oct 1, 2024

Describe this PR

This PR removes two environment variables from CI which have been used to carry credentials to publish/read packages to our GitHub Packages NuGet registry:

  • LBHPACKAGESTOKEN
  • NUGET_KEY

LBHPACKAGESTOKEN continues to be used for local development.

What is the problem we're trying to solve

Historically we've published packages from our local machines, which requires a token to authenticate with the GitHub Packages NuGet Registry. Now we use CI to publish packages there is a GitHub-managed token we can use instead..

If you're using a registry that supports granular permissions, and your workflow is using a personal access token to authenticate to the registry, then we highly recommend you update your workflow to use the GITHUB_TOKEN.
~ from https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#authenticating-to-package-registries-with-granular-permissions

This change removes both LBHPACKAGESTOKEN and NUGET_KEY tokens from the GitHub Actions workflow, replacing them where needed with the managed GITHUB_TOKEN token that's automatically made available to all jobs.

In order to keep the local development/management experience the same, references to LBHPACKAGESTOKEN have been kept as-is in the Docker and Docker Compose setup.

Docker's documentation suggests not to use build arguments to pass secrets, so this change updates the Dockerfile to use secret mounts, and the recommended way to manage secrets in docker compose.

Consequences

This will allow us to remove the shared secrets in GitHub Actions:

  • NUGET_KEY
  • LBHPACKAGESTOKEN

At the same time, this doesn't affect the local development workflow.

Checklist

  • Code pipeline builds correctly

Follow up actions after merging PR

@spikeheap spikeheap force-pushed the feature/github_token branch 2 times, most recently from 7375d06 to 21d383c Compare October 1, 2024 10:42
Historically we've published packages from our local machines, which requires a token
to authenticate with the GitHub Packages NuGet Registry. Now we use CI to publish
packages there is a GitHub-managed token we can use instead..

> If you're using a registry that supports granular permissions, and your workflow is using a personal access token to authenticate to the registry, then we highly recommend you update your workflow to use the GITHUB_TOKEN.
>  ~ from https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#authenticating-to-package-registries-with-granular-permissions

This change removes both `LBHPACKAGESTOKEN` and `NUGET_KEY` tokens from
the GitHub Actions workflow, replacing them where needed with the
managed `GITHUB_TOKEN` token that's automatically made available to all
jobs.

In order to keep the local development/management experience the same,
references to `LBHPACKAGESTOKEN` have been kept as-is in the Docker and
Docker Compose setup.

Docker's documentation
[suggests](https://docs.docker.com/reference/dockerfile/#arg) not to use
build arguments to pass secrets, so this change updates the `Dockerfile`
to use [secret
mounts](https://docs.docker.com/build/building/secrets/#secret-mounts),
and the recommended way to [manage secrets in docker
compose](https://docs.docker.com/compose/how-tos/use-secrets/).

Consequences

This will allow us to remove the shared secrets in GitHub Actions:

- `NUGET_KEY`
- `LBHPACKAGESTOKEN`

At the same time, this doesn't affect the local development
workflow.
@spikeheap spikeheap marked this pull request as ready for review October 1, 2024 10:57
@spikeheap spikeheap requested a review from a team as a code owner October 1, 2024 10:57
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