GitHub Workflow Fails to Deploy Backend Canisters – Need Help Debugging

Hi everyone,

I’m encountering an issue where my GitHub Actions workflow fails when attempting to deploy backend canisters to the IC. I’m using a dfx command in the workflow, and while it works locally, it consistently fails when running in the GitHub Actions environment.

Error: Failed to create canister 'provision'.
Caused by: No wallet configured for combination of identity 'actions' and network 'ic'
Error: Process completed with exit code 255.

Here’s the core part of my GitHub Actions workflow YAML:

jobs:
  test:
    name: Run Canister Test Suite
    runs-on: ubuntu-22.04

    steps:
      - name: Checkout Code
        uses: actions/checkout@v3
      - name: Cache install Nix packages
        uses: rikhuijzer/cache-install@v1.1.4
        with:
          key: nix-${{ hashFiles('default.nix') }}
      # - name: Install Rust
      #   run: |
      #     sudo apt update
      #     curl https://sh.rustup.rs -sSf | sh -s -- -y
      #     source $HOME/.cargo/env
      #     cargo install ic-cdk-optimizer

      - name: Cache rust dependencies, build output and DFX build cache
        uses: actions/cache@v3
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
            .dfx/
          key: rust-test-${{ hashFiles('**/Cargo.lock') }}

      - name: Import DFX Identity # Import DFX identity using secret key
        run: |
          touch actions_identity.pem
          echo "${{ secrets.FUEL_DAO_CANISTER_CONTROLLER_PRIVATE_KEY }}" > actions_identity.pem
          nix-shell --run "dfx identity import --disable-encryption actions actions_identity.pem"
          rm actions_identity.pem
          nix-shell --run "dfx identity use actions"
      - name: Start Local Replica # Start local DFX replica
        run: nix-shell --run "dfx start --background"

      - name: Use myidentity # Start local DFX replica
        run: nix-shell --run "dfx identity use actions"

      - name: check balance
        run: nix-shell --run "dfx cycles balance --network ic"

      - name: Deploy Backend Canister to ICP # Deploy canister to the Internet Computer
        env:
          ICP_NETWORK: ic # Specify the network to deploy to (default is 'ic')
        run: |
          nix-shell --run "dfx deploy backend --network ic --yes"
         
      - name: Deploy Provision Canister to ICP # Deploy canister to the Internet Computer
        env:
          ICP_NETWORK: ic # Specify the network to deploy to (default is 'ic')
        run: |
          nix-shell --run "dfx canister create provision --network ic"
          nix-shell --run "dfx deploy provision --network ic --yes"
      - name: Deploy Asset_proxy Canister to ICP # Deploy canister to the Internet Computer
        env:
          ICP_NETWORK: ic # Specify the network to deploy to (default is 'ic')
        run: |
          nix-shell --run "dfx canister create asset_proxy --network ic"
          nix-shell --run "dfx deploy asset_proxy --network ic --yes"
      - name: Deploy Asset Canister to ICP # Deploy canister to the Internet Computer
        env:
          ICP_NETWORK: ic # Specify the network to deploy to (default is 'ic')
        run: |
          nix-shell --run "dfx canister create asset --network ic"
          nix-shell --run "dfx deploy asset --network ic --yes"
      - name: Call Upload Asset Wasm Script 
        run: |
          chmod +x ./scripts/upload_asset_wasm.sh
          nix-shell --run "./scripts/upload_asset_wasm.sh"
      - name: Call Upload Token Wasm Script 
        run: |
          chmod +x ./scripts/upload_token_wasm.sh
          nix-shell --run "./scripts/upload_token_wasm.sh"
      - name: Stop Local Replica # Stop the local DFX replica
        run: nix-shell --run "dfx stop"

Since you have

      - name: check balance
        run: nix-shell --run "dfx cycles balance --network ic"

I assume you want to use cycles on the cycles ledger to create your canister. The error message you get tells me you are on a version of dfx that does not use the cycles ledger by default. If you update to a more recent version it should use the cycles ledger by default.

Aside: Do you really want to create new canisters every time in CI? The canister ids will not be persisted (unless you add some more logic to account for that). If you create the canister ids and check in canister_ids.json instead your workflow will update the canisters you already have.

Yes @Severin, It was the version problem only.
Thanks