TeamFx GitHub Action failing with teamsFx npm error

So when I try to run the action:

Run OfficeDev/teamsfx-cli-action@v1

I get the following error:

/usr/local/bin/npx teamsfx config set run-from GitHubAction
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/teamsfx - Not found
npm ERR! 404 
npm ERR! 404  'teamsfx@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-11-25T13_27_07_216Z-debug.log
Install for [ 'teamsfx@latest' ] failed with code 1
Error: The process '/usr/local/bin/npx' failed with exit code 1

I’m not sure what I am missing here, the ci/cd script I’m using is the default actions as described here

The script I have is very simple so I’m probably just missing something obvious:

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    env:
      AZURE_ACCOUNT_NAME: ${{secrets.AZURE_ACCOUNT_NAME}}
      AZURE_ACCOUNT_PASSWORD: ${{secrets.AZURE_ACCOUNT_PASSWORD}}
      AZURE_SUBSCRIPTION_ID: ${{secrets.AZURE_SUBSCRIPTION_ID}}
      AZURE_TENANT_ID: ${{secrets.AZURE_TENANT_ID}}
      M365_ACCOUNT_NAME: ${{secrets.M365_ACCOUNT_NAME}}
      M365_ACCOUNT_PASSWORD: ${{secrets.M365_ACCOUNT_PASSWORD}}
      M365_TENANT_ID: ${{secrets.M365_TENANT_ID}}

    steps:
      # Provision resources.
      - uses: OfficeDev/teamsfx-cli-action@v1
        with:
          commands: provision
          subscription: ${{env.AZURE_SUBSCRIPTION_ID}}
    
      # Deploy the code.
      - uses: OfficeDev/teamsfx-cli-action@v1
        with:
          commands: deploy

      # Publish the Teams App.
      - uses: OfficeDev/teamsfx-cli-action@v1
        with:
          commands: publish

Answer

You’re missing the teamsfx-cli. See docs:

"devDependencies": { "@microsoft/teamsfx-cli": "^0.3.1" }

Once that’s installed, the command npx teamsfx is going to work.


In terms of changes to your workflow, you probably want to checkout your project as a first step and then run an npm ci.