KatKibo
KatKibo

Reputation: 143

Create GitHub Action step output in TypeScript Code

Is there a way to create a step output from inside a code snippet that is executed by a GitHub Action step? My step is running a CDK deploy (TypeScript) command and I'd like to create some GHA outputs from the TypeScript code.

I tried using the code snippet below in TypeScript, but this did not create the outputs I expected:

const accessKey = new CfnAccessKey(this, 'testserKey', {
  userName: testUser.userName,
});

core.setOutput('devSecret', accessKey.attrSecretAccessKey);

This is how I'd like to use it in GH Actions:

  # step that should create the output
  - name: Run CDK deploy
    id: run-cdk
    run: cdk deploy --all --require-approval=never 
  
  # step that should use it
  - name: Use variable value
    run: echo ${{ steps.run-cdk.outputs.devSecret }}

Is there a way to achieve this?

Upvotes: 0

Views: 1039

Answers (1)

Michal
Michal

Reputation: 405

Are you using actions/toolkit properly? You should use core.setOutput to make output available for further use. Just like in example shown over here.

Upvotes: 1

Related Questions