最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

linux - How to run Cargo commands in an offline GitHub Actions pipeline with restricted environment? - Stack Overflow

programmeradmin6浏览0评论

I'm working with a GitHub Actions pipeline where the runners are offline, as the environment is restricted. I've already installed Rust and Cargo in the container, but when trying to run Cargo commands (such as cargo clean or cargo doc), I encounter an error:

error: could not download file from '.78.0.toml.sha256'

The goal is to run Cargo commands in this offline environment, but it seems like Cargo is attempting to fetch files from the internet, which isn't possible in this case.

Here is the GitHub Actions step I’m running:

   name: Check Cargo path and run cargo clean
   run: |
      docker run --rm -v $GITHUB_WORKSPACE:/workspace --workdir /workspace --entrypoint sh $container_cargo -c '
       set -e
       export CARGO_HOME=/root/.cargo;
       export RUSTUP_HOME=/root/.rustup;
       export PATH=$CARGO_HOME/bin:$PATH;

       export SOURCE_BRANCH=${{ github.ref_name }};
       echo 'Verifying rustup installation'
       rustup --version

       rustup target list --installed

       echo "Listing files in the current directory:";
       ls -l;  # List files in the current directory to verify Cargo.toml
       if command -v cargo &> /dev/null; then
         cargo --version && echo "Cargo found!";
         echo "Running cargo clean...";
         cargo clean;
         echo "Generating documentation with cargo doc...";
         cargo doc --no-deps;
      else
         echo "Cargo not found.";
      fi
    '
    docker run --rm $container_cargo cargo clean

  env:
     container_cargo:latest

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论