6

I am trying to get connection string using Powershell and pass this argument to another step in the actions, but I am getting this error:

Input required and not supplied: connection-string

But I am following a similar behaviour that I use before but I am not sure why it is not working, Here is part of my script:

      - name: Secrets to Key Vault
        uses: azure/powershell@v1
        env:
          POWERSHELL_TELEMETRY_OPTOUT: 1
        with:
          inlineScript: |
            $sqlConnectionString = (az keyvault secret show --vault-name <keyVaultName> --name <secret-name> --query [value] --output tsv)
            echo ::set-output name=sqlConnectionString::$( $sqlConnectionString)
          azPSVersion : '3.1.0'
        

      - name: Deploy Core Module
        uses: azure/sql-action@v1
        id: sqlConnection
        with:
          server-name: <sqlServerName>
          connection-string: ${{ steps.sqlConnection.outputs.sqlConnectionString}}
          dacpac-package: './Database.dacpac'

I think problem is related to the output of the variable but I use similar syntax previously just in a simple run and it worked. Could it be related to the behaviour of the Powershell?

2 Answers 2

6

Since the commands syntax to set the output is now deprecated in GitHub Actions, it can be set using the GITHUB_OUTPUT environment variable. So something like this:

        - name: Secrets to Key Vault
        uses: azure/powershell@v1
        id: setSqlConnection
        env:
          POWERSHELL_TELEMETRY_OPTOUT: 1
        with:
          inlineScript: |
            $sqlConnectionString = (az keyvault secret show --vault-name <keyVaultName> --name <secret-name> --query [value] --output tsv)
            Write-Output "sqlConnectionString=$($sqlConnectionString)" >> $Env:GITHUB_OUTPUT
          azPSVersion : '3.1.0'
      - name: Deploy Core Module
        uses: azure/sql-action@v1
        id: sqlConnection
        with:
          server-name: <sqlServerName>
          connection-string: ${{ steps.setSqlConnection.outputs.sqlConnectionString}}
          dacpac-package: './Database.dacpac'

Note: using the output variable in a later step remains unchanged.

Sign up to request clarification or add additional context in comments.

Comments

2

Plese add id to you first action:

      - name: Secrets to Key Vault
        uses: azure/powershell@v1
        id: setSqlConnection
        env:
          POWERSHELL_TELEMETRY_OPTOUT: 1
        with:
          inlineScript: |
            $sqlConnectionString = (az keyvault secret show --vault-name <keyVaultName> --name <secret-name> --query [value] --output tsv)
            echo ::set-output name=sqlConnectionString::$( $sqlConnectionString)
          azPSVersion : '3.1.0'
        

      - name: Deploy Core Module
        uses: azure/sql-action@v1
        id: sqlConnection
        with:
          server-name: <sqlServerName>
          connection-string: ${{ steps.setSqlConnection.outputs.sqlConnectionString}}
          dacpac-package: './Database.dacpac'

and then use it to access output ${{ steps.setSqlConnection.outputs.sqlConnectionString}}

1 Comment

Apparently ::set-output has been deprecated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.