From 3f8dc3eed75398519a06f6a0b9dd5db5f833dd74 Mon Sep 17 00:00:00 2001 From: Nicolas Riebesel Date: Thu, 27 Jun 2024 15:42:38 +0200 Subject: [PATCH] Add ability to fetch git dependecies in cargo via ssh (#78) --- Dockerfile | 6 +++--- action.yml | 15 +++++++++++++++ entrypoint.sh | 24 ++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5cd18a8..c8e867d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ -FROM rust:1.71.0-alpine3.18 +FROM rust:1.77.2-alpine3.19 -ENV deny_version="0.14.21" +ENV deny_version="0.14.22" RUN set -eux; \ apk update; \ - apk add bash curl git tar; \ + apk add bash curl git tar openssh; \ curl --silent -L https://github.com/EmbarkStudios/cargo-deny/releases/download/$deny_version/cargo-deny-$deny_version-x86_64-unknown-linux-musl.tar.gz | tar -xzv -C /usr/bin --strip-components=1; # Ensure rustup is up to date. diff --git a/action.yml b/action.yml index e6a902f..fc4dd3b 100644 --- a/action.yml +++ b/action.yml @@ -35,6 +35,18 @@ inputs: description: "The git credentials for credential.helper store using github username and github's private access token (PAT)" required: false default: "" + ssh-key: + description: "Set the used ssh key" + required: false + default: "" + ssh-known-hosts: + description: "Set ssh known hosts" + required: false + default: "" + use-git-cli: + description: "Set CARGO_NET_GIT_FETCH_WITH_CLI" + required: false + default: "false" runs: using: "docker" @@ -42,6 +54,9 @@ runs: args: - ${{ inputs.rust-version }} - ${{ inputs.credentials }} + - ${{ inputs.ssh-key }} + - ${{ inputs.ssh-known-hosts }} + - ${{ inputs.use-git-cli }} - --log-level - ${{ inputs.log-level }} - --manifest-path diff --git a/entrypoint.sh b/entrypoint.sh index 642fc5e..d3612a6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -19,6 +19,30 @@ then chmod 600 "$HOME/.git-credentials" fi +if [ -n "$3" ] +then + mkdir -p "/root/.ssh" + chmod 0700 "/root/.ssh" + echo "${3}" > "/root/.ssh/id_rsa" + chmod 0600 "/root/.ssh/id_rsa" +fi + +if [ -n "$4" ] +then + mkdir -p "/root/.ssh" + chmod 0700 "/root/.ssh" + echo "${4}" > "/root/.ssh/known_hosts" + chmod 0600 "/root/.ssh/known_hosts" +fi + +if [ -n "$5" ] +then + export CARGO_NET_GIT_FETCH_WITH_CLI="$5" +fi + +shift +shift +shift shift shift