pulumi / actions

Deploy continuously to your cloud of choice, using your favorite language, Pulumi, and GitHub!
Apache License 2.0
258 stars 72 forks source link

Integrate with GitHub Deployment API #796

Open jhamman opened 1 year ago

jhamman commented 1 year ago

Hello!

Issue details

It would be great if Pulumi's actions could integrate with GitHub's deployment API. This would be very helpful in tracking the status of deployments within the GitHub UI. I could imagine a 1:1 mapping of Pulumi stacks to GitHub Environments, similar to how Vercel does this.

image

Affected area/feature

I think this could be scoped to only impact the action itself. Ideally, Pulumi could seed the GitHub deployment API when the action starts and finalize its status when complete.

RobbieMcKinstry commented 1 year ago

Good thinking @jhamman! Thanks for referencing Vercel as an example workflow. I'll noodle on this a bit and ask a few colleagues for their thoughts. It's possible another team has implemented something similar.

RobbieMcKinstry commented 1 year ago

I checked in with the Service team. They suggested we could use Pulumi's SaaS to manage the callbacks. I'm inclined to go a simpler route, and suggest we re-implement the deployments logic.

It looks like this is doable with Octokit. I need to read the documentation, but I expect the workflow is something like:

This feels like it would accomplish the goal without ballooning the scope of this issue too much.

jhamman commented 1 year ago

Thanks @RobbieMcKinstry, fwiw, I've got a bit of a workaround working now:


    steps:

      - name: Turnstyle
        ...
      - uses: chrnorm/deployment-action@v2
        name: Create GitHub deployment
        id: deployment
        with:
          token: "${{ github.token }}"
          environment: dev
      ... # steps to setup deployment env
      - name: Apply infrastructure update
        uses: pulumi/actions@v3
        with:
          command: up
          stack-name: ${{ env.PULUMI_STACK_NAME }}
          work-dir: ${{ env.PULUMI_WORKING_DIRECTORY }}

      - name: Update deployment status (success)
        if: success()
        uses: chrnorm/deployment-status@v2
        with:
          token: "${{ github.token }}"
          environment-url: ${{ steps.pulumi.outputs.domain }}
          state: "success"
          deployment-id: ${{ steps.deployment.outputs.deployment_id }}

      - name: Update deployment status (failure)
        if: failure()
        uses: chrnorm/deployment-status@v2
        with:
          token: "${{ github.token }}"
          environment-url: ${{ steps.pulumi.outputs.domain }}
          state: "failure"
          deployment-id: ${{ steps.deployment.outputs.deployment_id }}

This works but it would be much nicer if the Pulumi action (or SaaS) did this for me :)

RobbieMcKinstry commented 1 year ago

Thanks for this example, @jhamman! Having this on hand will make it easier to implement, for sure!

nebbles commented 1 year ago

I had come here to check if Pulumi action did this out-the-box. My use case is that I thought this would fit very nicely with the branch-deploy model described^1 and published^2 by GitHub. By using the native deployments, it would be much easier to track and view those Pulumi deployments from GitHub.

@jhamman thanks for the workaround, I may give this a try in the meantime!