Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulumi/actions Github action should support mapping stack output to step outputs #43

Closed
amichel opened this issue Apr 3, 2020 · 6 comments
Assignees
Milestone

Comments

@amichel
Copy link

amichel commented Apr 3, 2020

In a workflow that has steps not managed by Pulumi, it is required sometimes to use variables from pulumi stack output. A clean way would be to have them available via the outputs of the "stack output" step.
E.g. a simple use case is when I provision buckets in S3 and need they names later on to upload artifacts or test results to S3

Currently I managed to do this in custom action that derives from pulumi/actions image using:

pulumi stack output -j | jq --raw-output 'to_entries | map("::set-output name=" + .key+"::" + (.value | tostring)+"^") | .[]' | xargs -d '^' echo 

calling it in a step and later in next steps using
${{ steps.pulumiOutput.outputs.myBucketName}}

I believe it should be easy to enable this in pulumi/actions , maybe even do it by default/with flag after pulumi up command, so no additional step will be required

@amichel
Copy link
Author

amichel commented Apr 10, 2020

Meanwhile I published this action to marketplace, if anyone needs
https://github.com/marketplace/actions/pulumi-stack

@leezen
Copy link
Contributor

leezen commented Apr 10, 2020

@amichel We'd be happy to take a look at a PR if you want to submit one

@amichel
Copy link
Author

amichel commented Apr 11, 2020

@amichel We'd be happy to take a look at a PR if you want to submit one

What branch should I target in PR? My initial commit was right on master.

@leezen
Copy link
Contributor

leezen commented Apr 13, 2020

That's fine if it's on master in your fork

amichel referenced this issue in amichel/pulumi Apr 13, 2020
Add support for stack output to Github Action step output. This works as standalone step (e.g. if stack output is passed in args) as well as after stack up, so no additional step is required in such case.
Currently only "all" value is supported in step input, which causes all stack outputs to be mapped to step output.
Usage:
```
 - name: Pulumi Stack
        id: pulumi
        uses: docker://pulumi/actions
        with:
          args: up
          MAP_OUTPUT: all
        env:
           AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
           AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
           PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
           PULUMI_CI: up
           PULUMI_ROOT: my-website-infra

 - name: Show Output
        run: |
          echo ${{steps.pulumi.outputs.targetBucket}}
          echo ${{steps.pulumi.outputs.targetBucketArn}}

 - name: S3 Sync
        id: s3
        uses: awact/s3-action@0.1.1
        with:
          args: --follow-symlinks --delete
        env:
          AWS_S3_BUCKET: ${{ steps.pulumi.outputs.targetBucket }}
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          AWS_REGION: "eu-west-1"
          SOURCE_DIR: "./my-website-pages"
```
@joeduffy
Copy link
Member

Please see https://www.azurefromthetrenches.com/integrating-pulumi-stack-output-with-github-actions/ for an end user's experience here. We should definitely make this easier, but in the meantime, hopefully this post helps others.

@stack72 stack72 transferred this issue from pulumi/pulumi Jan 4, 2021
@stack72 stack72 self-assigned this Feb 26, 2021
@stack72 stack72 added this to the 0.53 milestone Feb 26, 2021
@stack72
Copy link
Contributor

stack72 commented Feb 26, 2021

I am closing this out as we have just released v2 of our Action which is based on TypeScript and addresses this issue

@stack72 stack72 closed this as completed Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants