Skip to content

Commit

Permalink
Add ability to fetch git dependecies in cargo via ssh (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
nagua authored Jun 27, 2024
1 parent 3f4a782 commit 3f8dc3e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
15 changes: 15 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,28 @@ 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"
image: "Dockerfile"
args:
- ${{ inputs.rust-version }}
- ${{ inputs.credentials }}
- ${{ inputs.ssh-key }}
- ${{ inputs.ssh-known-hosts }}
- ${{ inputs.use-git-cli }}
- --log-level
- ${{ inputs.log-level }}
- --manifest-path
Expand Down
24 changes: 24 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3f8dc3e

Please sign in to comment.