actions icon indicating copy to clipboard operation
actions copied to clipboard

Integrate with GitHub Deployment API

Open jhamman opened this issue 2 years ago • 5 comments

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

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.

jhamman avatar Dec 08 '22 00:12 jhamman

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 avatar Dec 08 '22 05:12 RobbieMcKinstry

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:

  • [ ] Create a Deployment, providing the Environment and the SHA/commit/branch identifier.
  • [ ] After the run is complete, submit an Update Deployment Status request based on the status code.

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

RobbieMcKinstry avatar Dec 21 '22 00:12 RobbieMcKinstry

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 :)

jhamman avatar Dec 21 '22 18:12 jhamman

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

RobbieMcKinstry avatar Jan 11 '23 16:01 RobbieMcKinstry

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!

nebbles avatar Apr 09 '23 09:04 nebbles