Skip to content

Commit

Permalink
add git credentials as input parameter (#54)
Browse files Browse the repository at this point in the history
* add git credentials as input parameter

* update test.yml to work with new argument
  • Loading branch information
danielhaap83 authored Jul 19, 2022
1 parent 30ecad1 commit 7257a18
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
run: docker build -t test-cargo-deny .

- name: Run list
run: docker run -v ${PWD}/test:/test test-cargo-deny "" --manifest-path test/Cargo.toml list
run: docker run -v ${PWD}/test:/test test-cargo-deny "" "" --manifest-path test/Cargo.toml list

- name: Run check
run: docker run -v ${PWD}/test:/test test-cargo-deny 1.60.0 --manifest-path test/Cargo.toml --all-features check
run: docker run -v ${PWD}/test:/test test-cargo-deny 1.60.0 "" --manifest-path test/Cargo.toml --all-features check
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ The action has three optional inputs
* `log-level`: The log level to use for `cargo-deny`, default is `warn`
* `command`: The command to use for `cargo-deny`, default is `check`
* `arguments`: The argument to pass to `cargo-deny`, default is `--all-features`. See [Common Options](https://embarkstudios.github.io/cargo-deny/cli/common.html) for a list of the available options.
* `command-arguments` The argument to pass to the command, default is emtpy. See options for [each command](https://embarkstudios.github.io/cargo-deny/cli/index.html).
* `command-arguments` The argument to pass to the command, default is emtpy. See options for [each command](https://embarkstudios.github.io/cargo-deny/cli/index.html).
* `credentials` This argument stores the credentials in the file `$HOME/git-credentials`, and configures git to use it. The credential must match the format `https://user:[email protected]`

### Example pipeline

Expand Down Expand Up @@ -54,6 +55,7 @@ jobs:
command: check
arguments: --all-features
command-arguments: ""
credentials: https://${{ secrets.GITHUB_USER }}:${{ secrets.GITHUB_PAT }}@github.com
```
### Use specific Rust version
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ inputs:
description: "The Rust version that is updated to before running cargo deny"
required: false
default: ""
credentials:
description: "The git credentials for credential.helper store using github username and github's private access token (PAT)"
required: false
default: ""

runs:
using: "docker"
image: "Dockerfile"
args:
- ${{ inputs.rust-version }}
- ${{ inputs.credentials }}
- --log-level
- ${{ inputs.log-level }}
- ${{ inputs.arguments }}
Expand Down
11 changes: 11 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ then
rustup default "$1"
fi

if [ -n "$2" ]
then
git config --global credential.helper store
git config --global --replace-all url.https://github.com/.insteadOf ssh://[email protected]/
git config --global --add url.https://github.com/.insteadOf [email protected]:

echo $2 > $HOME/.git-credentials
chmod 600 $HOME/.git-credentials
fi

shift
shift

cargo-deny $*

0 comments on commit 7257a18

Please sign in to comment.