Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GitHub Deployments

Actions
GitHub action for working painlessly with deployment statuses
v1.5.0
Latest
Star (401)

GitHub DeploymentsView Actionpipeline

bobheadxi/deployments is aGitHub Action for working painlessly withGitHub deployment statuses.Instead of exposing convoluted Action configuration that mirrors that of theGitHub API like some of the other available Actions do, this Action simply exposes a number of configurable, easy-to-use "steps" common to most deployment lifecycles.

📢 This project is in need of additional maintainers - if you are interested in helping out pleaselet me know!

A simple example:

on:push:branches:    -mainjobs:deploy:runs-on:ubuntu-lateststeps:    -name:start deploymentuses:bobheadxi/deployments@v1id:deploymentwith:step:starttoken:${{ secrets.GITHUB_TOKEN }}env:release    -name:do my deploy# ...    -name:update deployment statususes:bobheadxi/deployments@v1if:always()with:step:finishtoken:${{ secrets.GITHUB_TOKEN }}status:${{ job.status }}env:${{ steps.deployment.outputs.env }}deployment_id:${{ steps.deployment.outputs.deployment_id }}

You can also refer to other projects that also use this action - you can findmore usages of this action on Sourcegraph, or check out the following examples:

Also feel free to chime in on theshow and tell discussion to share your usages of this Action!

Check outthis blog post for a bit of background on the origins of this project.

Configuration

The followinginputs configuration options are forall steps:

VariableDefaultPurpose
stepOne ofstart,finish,deactivate-env, ordelete-env
token${{ github.token }}provide your${{ github.token }} or${{ secrets.GITHUB_TOKEN }} for API access
envidentifier for environment to deploy to (e.g.staging,prod,main)
repositoryCurrent repositorytarget a specific repository for updates, e.g.owner/repo
logsURL to GitHub commit checksURL of your deployment logs
descGitHub-generated descriptiondescription for this deployment
refgithub.refSpecify a particular git ref to use, (e.g.${{ github.head_ref }})

step: start

This is best used on thepush: { branches: [ ... ] } event, but you can also haverelease: { types: [ published ] } trigger this event.start should be followed by whatever deployment tasks you want to do, and it creates and marks a deployment as "started":

deploy started

In addition to thecore configuration, the followinginputs are available:

VariableDefaultPurpose
deployment_idUse an existing deployment instead of creating a new one (e.g.${{ github.event.deployment.id }})
overridefalsewhether to mark existing deployments of this environment as inactive
payloadJSON-formatted dictionary with extra information about the deployment
task'deploy'change the task associated with this deployment, can be any string

The followingoutputs are available:

VariablePurpose
deployment_idID of created GitHub deployment
status_idID of created GitHub deployment status
envname of configured environment
Simple Push Example

on:push:branches:    -mainjobs:deploy:steps:    -name:start deploymentuses:bobheadxi/deployments@v1id:deploymentwith:step:startenv:release    -name:do my deploy# ...


Simple Pull Request Example

on:pull_request:jobs:deploy:runs-on:ubuntu-lateststeps:    -name:start deploymentuses:bobheadxi/deployments@v1id:deploymentwith:step:startenv:integration    -name:do my deploy# ...


step: finish

This is best used afterstep: start and should follow whatever deployment tasks you want to do in the same workflow.finish marks an in-progress deployment as complete:

deploy finished

In addition to thecore configuration, the followinginputs are available:

VariableDefaultPurpose
statusprovide the current deployment job status${{ job.status }}
deployment_ididentifier for deployment to update (see outputs ofstep: start)
env_urlURL to view deployed environment
overridetruewhether to manually mark existing deployments of this environment as inactive
auto_inactivefalsewhether to let GitHub handle marking existing deployments of this environment as inactive (if and only if a new deployment succeeds).
Simple Example

# ...jobs:deploy:steps:    -name:start deployment# ... see previous example    -name:do my deploy# ...    -name:update deployment statususes:bobheadxi/deployments@v1if:always()with:step:finishtoken:${{ secrets.GITHUB_TOKEN }}status:${{ job.status }}env:${{ steps.deployment.outputs.env }}deployment_id:${{ steps.deployment.outputs.deployment_id }}


step: deactivate-env

This is best used on thepull_request: { types: [ closed ] } event, since GitHub does not seem to provide a event to detect when branches are deleted.This step can be used to automatically shut down deployments you create on pull requests and mark environments as destroyed:

env destroyed

Refer to thecore configuration for availableinputs.

Simple Example

on:pull_request:types:[ closed ]jobs:prune:steps:# see https://dev.to/bobheadxi/branch-previews-with-google-app-engine-and-github-actions-3pco    -name:extract branch nameid:get_branchshell:bashenv:PR_HEAD:${{ github.head_ref }}run:echo "##[set-output name=branch;]$(echo ${PR_HEAD#refs/heads/} | tr / -)"    -name:do my deployment shutdown# ...    -name:mark environment as deactivateduses:bobheadxi/deployments@v1with:step:deactivate-envtoken:${{ secrets.GITHUB_TOKEN }}env:${{ steps.get_branch.outputs.branch }}desc:Environment was pruned

step: delete-env

This is the same asdeactivate-env, except deletes the environment entirely. Seestep: deactivate-env for more details.

Note that the defaultGITHUB_TOKEN does not allow environment deletion - you have to set a personal access token withdeployments:write andadministration:write permissions and provide it in thetoken input.

Refer to thecore configuration for availableinputs.


Debugging

The argumentdebug: true can be provided to print arguments used bydeployments and log debug information.

If you run into an problems or have any questions, feel free to open anissue ordiscussion!


Migrating to v1

bobheadxi/deployments@v1 makes the following breaking changes fromv0.6.x:

  • CHANGED:no_override is nowoverride, and the default behaviour isoverride: true instep: finish (step: start behaviour remains unchanged, but you can now setoverride: true on it now as well).
  • CHANGED:log_args is nowdebug, but does the same thing as before.
  • CHANGED:env is now always required. You can useenv: ${{ steps.deployment.outputs.env }} to avoid repeating your env configuration.
  • REMOVED:transient - all deployments created by this action aretransient by default, with removals handled byoverride,auto_inactive, orstep: deactivate-env.
  • ADDED:step: delete-env deletes an environment entirely.

Then you can change your workflow to target thev1 tag, and automatically receive updates going forward:

- uses: bobheadxi/deployments@v0.6.2+ uses: bobheadxi/deployments@v1

Migrating to v1.2.0

Thetoken configuration variable now has a default value so if you are happy with the default (${{ github.secret }}) you can simplify the action configuration by removing this from your actions.


GitHub Deployments is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

GitHub action for working painlessly with deployment statuses
v1.5.0
Latest

GitHub Deployments is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.


[8]ページ先頭

©2009-2025 Movatter.jp