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 git credentials as input parameter #54

Merged
merged 2 commits into from Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
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
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:pass@github.com`

### 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
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
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://git@github.com/
git config --global --add url.https://github.com/.insteadOf git@github.com:

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

shift
shift

cargo-deny $*