0

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?

1 Answer 1

1

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.

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

8 Comments

Tried adding it this way: core.setOutput(Value, value), but it does not work unfortunately.
Well, it's nice to see some more details after you've edit OP... It's also nice that now you are using actions/toolkit but to locate the problem i'm afraid you will need to show more details of your solution because on this stage we don't even know how your logs looks like.
The logs suggest the variable is not created or is not created at the right place. I'm creating it inside the CDK code, so maybe it's created in a complete different place. Not sure what else I can show.
I would suggest to use a bottom-up approach of solving problems. Simply first check if everything is ok with your script - debug it. Next check your cdk setup. Does your script works properly in manual/managed launch? Last check gh actions setup. Does your workflow config installs cdk properly? You can also enable debug logging and analyze it.
Yeah, it works correctly. I added a GHA step to see if the output file is created with --out-file and piped back it's output to another step, that works. The only thing that is not working is the core.setOutput().
|

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.