Skip to content

Commit

Permalink
Add credentials via environment variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaal committed Jan 18, 2023
1 parent fdb80af commit 465a17c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
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

0 comments on commit 465a17c

Please sign in to comment.