在 Github 操作中使用 Powershell 的输出

Using outputs of Powershell in Github Actions

我正在尝试使用 Powershell 获取连接字符串并将此参数传递给操作中的另一个步骤,但出现此错误:

Input required and not supplied: connection-string

但我正在遵循我以前使用过的类似行为,但我不确定为什么它不起作用,这是我的脚本的一部分:

      - 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'

我认为问题与变量的输出有关,但我以前只是在一个简单的 运行 中使用了类似的语法并且它起作用了。它可能与 Powershell 的行为有关吗?

请先为您添加 id:

      - 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'

然后用它来访问输出${{ steps.setSqlConnection.outputs.sqlConnectionString}}