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

Add credentials via environment variable. #889

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ Variable Name | Default | Notes
`BRANCH ` | N/A (Optional) | Branch to fetch manifest from and open pull requests against.
`PULL_REQUESTS_ASSIGNEE` | N/A (Optional) | User to assign to the created pull request.
`OPTIONS` | `{}` | JSON options to customize the operation of Dependabot
`CREDENTIALS` | `[]` | JSON array containing credentials that can be used to specify what additional resources Dependabot can access and how it can access them.

The content of both the OPTIONS and CREDENTIALS variables depend on the selected package manager. For example, when using "maven", the CREDENTIALS variable can be used to specify an
additional repository or to completely replace the default maven central repository with a custom one:

```shell
export CREDENTIALS='[{"type": "maven_repository", "url": "https://example.com/maven", "replaces-base": true}]'
```

There are other variables that you must pass to your container that will depend on the Git source you use:

Expand Down
17 changes: 9 additions & 8 deletions generic-update-script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
require "gitlab"
require "json"

credentials = [
{
"type" => "git_source",
"host" => "github.com",
"username" => "x-access-token",
"password" => ENV["GITHUB_ACCESS_TOKEN"] # A GitHub access token with read access to public repos
}
]
# Get optional credentials from the environment variable called CREDENTIALS (json array).
credentials = JSON.parse(ENV["CREDENTIALS"] || "[]")

credentials << {
"type" => "git_source",
"host" => "github.com",
"username" => "x-access-token",
"password" => ENV["GITHUB_ACCESS_TOKEN"] # A GitHub access token with read access to public repos
}

# Full name of the repo you want to create pull requests for.
repo_name = ENV["PROJECT_PATH"] # namespace/project
Expand Down