chrnorm / deployment-action Goto Github PK
View Code? Open in Web Editor NEWGitHub action to create a Deployment
License: MIT License
GitHub action to create a Deployment
License: MIT License
Line 8 in fad9de7
In this action and in https://github.com/chrnorm/deployment-status I believe you need to include the following media types:
application/vnd.github.flash-preview+json
application/vnd.github.ant-man-preview+json
Here's an example failure https://github.com/sjparkinson/isitup.org/commit/8f493dc202948137370dddc9c002733194d985d9/checks.
##[error]HttpError: Validation Failed
##[error]Validation Failed
##[error]Node run failed with exit code 1
Heads up! Currently, there is a GitHub Actions limitation where events fired inside an action will not trigger further workflows. If you use this action in your workflow, it will not trigger any "Deployment" workflows.
I was able to work around this. While not ideal, if you use a token that is not the Action's GITHUB_TOKEN
, this will work. I define a secret called GITHUB_DEPLOY_TOKEN
and use that for API calls.
https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#deployment
It would be great to support all the possible properties, I am intending on using this action but also need the task property
Your action yaml is pointing to lib/main.js
but the new auto_merge
option is not present here on the tagged release: https://github.com/chrnorm/deployment-action/blob/v1.1.0/lib/main.js
This is causing the action to fail for us with similar errors to #1
Run chrnorm/[email protected]
with:
environment: production
initial_status: success
target_url: ***
token: ***
##[error]HttpError: Conflict merging development into refs/heads/master.
##[error]Conflict merging development into refs/heads/master.
##[error]Node run failed with exit code 1
I have a need to run a script with private runner that is Windows Server.
This action is not compatible with windows runner, and so I have split the jobs, where the first job creates the deployment and then uploads the deployment_id as artifact.
The second job runs the script on private runner.
The third job downloads the artifacts and sets the deployment id as env var and I have tried passing the deployment id as env var but the action is complaining with below error.
Error: HttpError: Invalid value for parameter 'deployment_id': null is NaN
Error: Invalid value for parameter 'deployment_id': null is NaN
Stage 3
DBUP-Git-Deployment-Status-Update:
runs-on: ubuntu-latest
needs: DBUP-Start-Deployment
defaults:
run:
shell: pwsh
steps:
- name: Download the deployment_id
uses: actions/download-artifact@v2
with:
name: deployment_id
- name: Set deloyment_id as envvar
run: |
$env:deployment_id = Get-content deployment_id.txt
Write-Output "printing file contents"
Get-content deployment_id.txt
Write-Output "printing env var"
$env:deployment_id
- name: Update deployment status (success)
if: success()
uses: chrnorm/deployment-status@releases/v1
with:
token: "${{ env.Password }}"
state: "success"
deployment_id: "${{ env.deployment_id }}"
- name: Update deployment status (failure)
if: failure()
uses: chrnorm/deployment-status@releases/v1
with:
token: "${{ env.Password }}"
state: "failure"
deployment_id: "${{ env.deployment_id }}"
GitHub is deprecating echo "::set-output name=etc::etc"
in favor of a new syntax.
Run chrnorm/deployment-action@v2
::set-output name=deployment_id::680226386
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
##[debug]steps.gh_deploy.outputs.deployment_id='680226386'
First of all, thank you for publishing this action. I have been using it for 1.5 years to track deployments by GitHub Actions and it works very well.
However, today I found out that GitHub Actions now has its own feature to manage deployments. By adding environment: production
to a job, GitHub Actions will create a deployment (and an environment, if it doesn't exist yet) and update its status based on the result of the job.
The URL for the deployment can also be specified, which is then also shown in the visualization graph for the workflow run:
And the deployment history will now show the user who triggered the deployment instead of github-actions:
So I am opening this issue to discuss the question whether or not this action is still relevant. Is all the provided functionality now covered by GitHub Actions itself? Or are there still reasons / scenarios for which this action is offering functionality not covered by GitHub Actions?
Hi there!
In docs, you write:
target_url | (Optional) The target URL. This should be the URL of the app once deployed
But it is actually not true (source):
The target URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. Default: "" Note: It's recommended to use the log_url parameter, which replaces target_url.
As well it is deprecated and should use log_url instead.
Another thing, in your examples you use input target-url
with dash, instead of underscore.
Do you plan adding environment_url
input support?
Thank you
I tried to set 'in_progress' state for deployment instead of 'pending' and got the error:
Warning: Unexpected input(s) 'state', valid inputs are ['repo', 'owner', 'initial-status', 'token', 'log-url', 'description', 'environment', 'environment-url', 'auto-merge', 'ref', 'sha', 'task', 'required-contexts', 'payload', 'transient-environment', 'production-environment', 'auto-inactive', 'github-base-url']
Workflow code:
- name: Create GitHub deployment
uses: chrnorm/deployment-action@v2
id: deployment
with:
token: '${{ github.token }}'
environment: production
state: 'in_progress'
Getting the error below :
Run "chrnorm/deployment-action@6e62572 "
Error: HttpError: Not Found
Error: Error creating GitHub deployment: Not Found
Hi @chrnorm ,
Create deployment action is failing with below, do you have any ideas on where to actually look at:
Run chrnorm/[email protected]
with:
token: ***
environment: test
initial-status: pending
auto-merge: false
task: deploy
transient-environment: false
auto-inactive: true
Error: HttpError: invalid json response body at <URL HIDDEN> reason: Unexpected end of JSON input
Error: Error creating GitHub deployment: invalid json response body at <HIDDEN URL> reason: Unexpected end of JSON input
The hidden URL shows this:
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest/deployments/statuses#list-deployment-statuses"
}
It seems like we are hitting a no 'ID' case, somehow at the time of running of the below if check:
However, when I run a postman get to the statuses, I get back a response with the ID. So the deployment is actually created.
Any ideas?
Hi there, I have successfully used this action in a develop
branch. After merging into master
it fails with:
##[error]HttpError: Conflict merging develop into refs/heads/master.
##[error]Conflict merging develop into refs/heads/master.
##[error]Node run failed with exit code 1
I don't understand this output, there were no conflicts merging the PR, it was merged. This workflow is running on push
events, so it would be triggered on a new clean master commit.
As you can see, the merge was successful:
Any idea what's going on?
Thank you,
Tiago
All of the documentation for GitHub Actions uses the kebab-case naming convention. This project, however, uses snake-case. As such, it's the only part of our entire CD config that uses snake-case and it can throw people off.
I wouldn't want to break anything on anyone, so if supporting both isn't a problem, that'd be helpful. I can do up a PR for it, but don't want to spend the time if there's no support for the change.
Node 16 is EOL and GH actions are transitioning
Both deployment-action
and deployment-status
are useful and works nicely together.
But using both of them comes with a duplication of the configuration data, and make the workflow a bit too complex.
GitHub Actions support a nice (actually quite common) feature: runs.post
.
The most obvious usage of this feature is for caching data at the end of a job, like actions/setup-node
.
Using this with deployment-action
could be very valuable as well:
post
script, not limited to success onlyGithub will drop support for Node 12, any runs using this action will show a warning:
Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: chrnorm/deployment-action
Example usage says environment: production
but environment
is not listed in the section above.
Instead of changing the status of a running deployment, it seems to create a new one as if the deployment_id variable wasn't given.
name: Deploy
on:
push:
branches:
- master
jobs:
deploy:
name: Terraform
runs-on: ubuntu-latest
steps:
- uses: chrnorm/[email protected]
name: Create GitHub deployment
id: deployment
with:
token: ${{ secrets.GITHUB_TOKEN }}
target-url: https://cluster.ironpeak.be/
environment: production
initial_status: in_progress
- run: exit 1
- uses: chrnorm/[email protected]
name: "Set GitHub Deployment: Success"
if: success()
with:
token: ${{ secrets.GITHUB_TOKEN }}
state: "success"
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
- uses: chrnorm/[email protected]
name: "Set GitHub Deployment: Failed"
if: failure()
with:
token: ${{ secrets.GITHUB_TOKEN }}
state: "failure"
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
Deployments for the same commit:
And you can see the commit failed here in the CI/CD run: https://github.com/ironPeakServices/infrastructure/runs/497252378?check_suite_focus=true
Error: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter ''using: node20' is not supported, use 'docker', 'node12' or 'node16' instead.')
Error: Fail to load chrnorm/deployment-action/v2/action.yml
For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.
This action should be updated to Node.js 16 (atleast).
This is all that is shown if the configured user's github token does not have permissions to create deployments on the repository:
> Run chrnorm/[email protected]
Error: HttpError: Not Found
Error: Not Found
It'd be a lot more helpful if the messaging indicated that this HTTP error was specifically related to the call to the github api (and not that the target_url
is attempted to be queried for some reason, which was my first hunch since I had provided an internal server).
Error: Unable to create deployment. Either the repository does not exist or the provided token does not have the proper permissions to do so.
Hey. I noticed that this action does not respect https://github.blog/changelog/2021-02-17-github-actions-limit-which-branches-can-deploy-to-an-environment/ - meaning anybody can change an action in a PR and curl a secret to their server etc. if it's the only thing that you use for deployments
I assume this is contrary to using standard GitHub environment tag
I understand that this action is a github's deployment api helper and doesn't have access to the same APIs as whatever github employees write.
I was wondering if I'm on the right track with my thinking? If I want the security (deploy branch protection, deployment acceptance by a team member) features I should use the default GitHub YAML environment:
tag on a job, and only use this action (or deployment-status) for more granular control when I need it?
Instead of:
owner: context.repo.owner,
repo: context.repo.repo,
Create additional owner
and repo
inputs like in the original POST request (https://docs.github.com/en/rest/reference/repos#create-a-deployment)
await octokit.request('POST /repos/{owner}/{repo}/deployments', {
owner: 'octocat',
repo: 'hello-world',
ref: 'ref'
})
This way we can start deployments from another repository...
Currently ref
is not provided, will be set to github.ref
however, in the context of a PR this won't associate the deployment with the pull request and thus it won't show up as a deployment.
I'd suggest that you default ref
to github.head_ref
if the action is called within a pull request. You'd do this trivially by checking for the existence of it, because it is only available when the event that triggers a workflow run is a pull_request.
I'd do it myself, however I am afraid of changing documentation and actually is is a breaking change...
name: "Wipe environment"
on:
pull_request:
types: [closed]
jobs:
wipe:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v2
with:
registry-url: 'https://registry.npmjs.org'
- name: Remove from S3
uses: vitorsgomes/s3-rm-action@master
with:
args: --recursive
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_S3_BUCKET: ${{ secrets.AWS_BUCKET }}
PATH_TO_DELETE: /pr-${{ github.event.pull_request.number }}
- uses: chrnorm/deployment-status@releases/v1
if: success()
with:
token: ${{ secrets.GITHUB_TOKEN }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
state: inactive
Question is simple: how to retrieve the deployment_id
?
Hello.
Just noticed that documentation specifies:
production-environment | (Optional) Specifies if the given environment is one that end-users directly interact with. Default: true when environment is production and false otherwise.
but GitHub API returns "production_environment": false
when asked about created deployment:
[
{
"url": "https://api.github.com/repos/XXXXX/XXXXXX/deployments/571000164",
"id": 571000164,
"node_id": "DE_kwDODNDcKM4iCMVk",
"task": "deploy",
"original_environment": "production",
"environment": "production",
"description": "Deploy of v1.704.0",
"created_at": "2022-05-26T08:18:42Z",
"updated_at": "2022-05-26T08:19:34Z",
"statuses_url": "https://api.github.com/repos/XXXXX/XXXXXX/deployments/571000164/statuses",
"repository_url": "https://api.github.com/repos/XXXXX/XXXXXX",
"creator": {
"login": "github-actions[bot]",
"id": 41898282,
"node_id": "MDM6Qm90NDE4OTgyODI=",
"avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/github-actions%5Bbot%5D",
"html_url": "https://github.com/apps/github-actions",
"followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
"following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
"gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
"starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
"organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
"repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
"events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
"received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
"type": "Bot",
"site_admin": false
},
"sha": "b7209186793095ca0c4bb72103f507b5645d76d0",
"ref": "v1.704.0",
"payload": {},
"transient_environment": false,
"production_environment": false,
"performed_via_github_app": null
}
]
I'm using this action like this:
- name: Create GitHub deployment
uses: chrnorm/deployment-action@v2
id: deployment
with:
token: "${{ secrets.GITHUB_TOKEN }}"
environment-url: "${{ env.APP_VERSION_URL}}"
environment: "production"
initial-status: "in_progress"
description: "Deploy of ${{ steps.version.outputs.ref }}"
log-url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
ref: "${{ steps.version.outputs.ref }}"
Am I doing something wrong? Thanks.
Hi,
We are trying to use this action with our on-prem github enterprise server but this action only works with github.com. Is there anyway you can make this work with on-prem server as well? We just need to update the baseUrl from the URL below.
https://github.com/chrnorm/deployment-action/blob/master/dist/index.js#L4673
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.