Skip to content

Support injecting steps in the plan job.Β #2446

Description

@Remi-Godin

I recently ran into an issue in a rust project when using crates from private repos. When the CI pipeline runs the "plan" job, it doesn't have the injected steps from the github-build-setup file.

I'm trying to inject this in the plan job (since I'm using ssh to pull from the GitHub repo in my Cargo.toml file):

      - name: Setup SSH key for cargo dependencies
        uses: webfactory/ssh-agent@v0.10.0
        with:
          ssh-private-key: ${{ secrets.CRATE_DEPLOY_KEY }}

Cargo.toml example:

[workspace.dependencies]
private-crate = { git = "ssh://git@github.com/my-org/private-crate.git", tag = "v0.5.0" }

Error from GitHub actions CI run:

Run dist plan --output-format=json > plan-dist-manifest.json
  Γ— We encountered an issue trying to read your workspace
  β”œβ”€β–Ά   Γ— `cargo metadata` execution failed
  β”‚   
  ╰─▢ `cargo metadata` exited with an error:     Updating crates.io index
          Updating git repository `ssh://git@github.com/my-org/private-crate.git`
      error: failed to get `private-crate` as a dependency of package `my-app v1.6.0 (/home/runner/work/my-
      app/my-app-repo/apps/my-app-dir)`
      
      Caused by:
        failed to load source for dependency `private-crate`
      
      Caused by:
        unable to update ssh://git@github.com/my-org/private-crate.git?tag=v0.5.0#bcddefb1
      
      Caused by:
        failed to clone into: /home/runner/.cargo/git/db/private-crate-1bb41a8a83d12937
      
      Caused by:
        revision bcddefb159143c840ee27eddd8f6803efe6897eb not found
      
      Caused by:
        failed to authenticate when downloading repository
      
        * attempted ssh-agent authentication, but no usernames succeeded: `git`
      
        if the git CLI succeeds then `net.git-fetch-with-cli` may help here
        https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
      
      Caused by:
        no authentication methods succeeded

The current github-build-setup only injects this in the build-local-artifacts job. I also tested adding the step manually in the plan job to confirm this would fix the issue and it did.

I see that there was a similar issue opened already in #2065 , and a matching, but seemingly abandoned pull request #2070. Was there any plan on eventually including this change in the main branch? Or was a different approach preferred? In any case, I think having a way to inject tokens and other types of credentials could be beneficial when working on private repos.

Or is this issue already solved and there is documentation on how to address this problem? If so, I would appreciate a link if possible, as I wasn't able to find it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions