Get deployment id in GitHub Action

Hi there. I’m currently using GitHub Deployments by setting the environment like so:

jobs:
  review_app:
    runs-on: ubuntu-latest

    # deploy to the review environment
    environment:
      name: review
      url: http://example.com

GitHub will automatically create the deployment and update the deployment status, so I don’t need to call any api’s. This works great.

The problem I have is I need to delete the deployment when, for example, a pull request is closed. And to do that I need the deployment id.

How can I get the deployment id? I’ve inspected all of the context available and can’t find any reference to the deployment id.

Hopefully we can work out on a feature soon to address this, this was discussed.

There is no deployment Id that’s available from context unfortunately.

May be Repositories - GitHub Docs can be used to workaround that.

1 Like