personaelit
personaelit

Reputation: 1653

What does an error about not valid "name of the environment used by the job" mean and how to fix or suppress it?

I get an error in VS Code in my YAML deployment file:

Value 'Development' is not valid
The name of the environment used by the job.

Available expression contexts: github, inputs, vars, needs, strategy, matrix

Here is the YAML in question:

  deploy:
    permissions:
      contents: none
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: 'Development' # This line causes an error to be listed in the PROBLEMS pane of VS Code.
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

    steps:
    - name: Download artifact from build job
      uses: actions/download-artifact@v4
      with:
        name: node-app

    - name: 'Deploy to Azure WebApp'
      id: deploy-to-webapp
      uses: azure/webapps-deploy@v2
      with:
        app-name: ${{ env.AZURE_WEBAPP_NAME }}
        publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
        package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}


I have verified that I have environment in the deployments section of GitHub called Development.

I could suppress all YAML errors by adding "yaml.validate": false to my settings.json file, but I don't want to do that.

Not sure what else to try. It's just a minor annoyance because the deployments still work, but I cherish having no problems listed in VS Code.

Upvotes: 0

Views: 36

Answers (1)

bigmacsetnotenough
bigmacsetnotenough

Reputation: 112

This error is a false positive caused by the YAML schema expecting an expression for the environment name, even though a static string is valid.

possible solution is to modify the environment block to use an explicit expression.

environment:
  name: ${{ 'Development' }}  # Wrap the string in an expression
  url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

Upvotes: 1

Related Questions