webfactory / ssh-agent

GitHub Action to setup `ssh-agent` with a private key
MIT License
1.23k stars 256 forks source link

Cargo Dependencies on Linux Runner #224

Open Abhay2412 opened 3 months ago

Abhay2412 commented 3 months ago

Hello, I am trying to run a workflow to make a deb file for a Flutter project that communicates with Rust. We have some private repos that are being called in our project as dependencies.

According to the documentation this works for Windows I tried adding it to my workflow as well https://github.com/marketplace/actions/webfactory-ssh-agent#cargos-rust-private-dependencies-on-windows but I am still get an error for some reason:

name: Building App on Linux
on:
  push:
    branches:
      - workflows
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Configure git to use SSH
        run: |
          git config --global url."ssh://git@github.com/".insteadOf "https://github.com/"
      - name: Give GitHub Actions access to Crate 1 Repo
        uses: webfactory/ssh-agent@v0.9.0
        with:
          ssh-private-key: ${{ secrets.CRATE1DEPLOYKEY }}
      - name: Give GitHub Actions access to Crate 2 Repo
        uses: webfactory/ssh-agent@v0.9.0
        with:
          ssh-private-key: ${{ secrets.CRATE2DEPLOYKEY }}
      - name: Give GitHub Actions access to Crate 3 Repo
        uses: webfactory/ssh-agent@v0.9.0
        with:
          ssh-private-key: ${{ secrets.CRATE3DEPLOYKEY }}
      - name: Give GitHub Actions access to Crate 4 Repo
        uses: webfactory/ssh-agent@v0.9.0
        with:
          ssh-private-key: ${{ secrets.CRATE4DEPLOYKEY }}
      - name: Add GitHub to known hosts
        run: |
          mkdir -p ~/.ssh
          ssh-keyscan github.com >> ~/.ssh/known_hosts
      - name: Update cargo config to use Git CLI
        run: echo -e "[net]\ngit-fetch-with-cli = true" > ~/.cargo/config.toml  
      - uses: subosito/flutter-action@v2
        with:
          flutter-version: "3.x"
          cache: true
          channel: stable
      - name: Install dependencies
        run: |
          flutter pub get
          sudo apt-get install clang cmake git ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev
      - name: Build Linux Distribution
        run: |
          dart pub global activate flutter_distributor
          flutter_distributor release --name=dev --jobs=release-dev-linux-deb
      - name: Upload Distribution
        uses: actions/upload-artifact@v2
        with:
          name: linux-deb
          path: dist/

The Cargo.toml file:

[package]
name = "app"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "staticlib"]

[dependencies]
flutter_rust_bridge = "=2.1.0"
anyhow = "1.0.86"
lazy_static = "1.5.0"
plotters = "0.3.6"
rustfft = "6.2.0"

CRATE1= { git = "ssh://git@github.com/{Crate1Repo}.git" }
CRATE2= { git = "ssh://git@github.com/{Crate2Repo}.git" }
CRATE3= { git = "ssh://git@github.com/{Crate3Repo}.git" }
CRATE4= { git = "ssh://git@github.com/{Crate4Repo}.git" }

The error I get when the workflow gets to the step of Building the Linux distribution: SEVERE: error: failed to get `CRATE1` as a dependency of package `app v0.1.0 I'm hoping to get some insight on what I'm doing wrong and guidance.

boroskoyo commented 3 months ago

Hi, i've just faced a similar issue and this article helped me about the setup: https://adventures.michaelfbryan.com/posts/configuring-cargo-auth-in-github-actions/

other than that since all your git strings are already starting with "ssh://..."

seems redundant

Abhay2412 commented 3 months ago

Hi, i've just faced a similar issue and this article helped me about the setup: https://adventures.michaelfbryan.com/posts/configuring-cargo-auth-in-github-actions/

other than that since all your git strings are already starting with "ssh://..."

seems redundant

Appreciate the feedback and your reply I think the ssh agent step works it's just for some reason Cargo.toml is not able to recognize the repos maybe some configuration settings I am missing and thanks for the article was following it.