Skip to content

Commit

Permalink
Merge branch 'main' into releases/v2
Browse files Browse the repository at this point in the history
  • Loading branch information
chrnorm committed May 22, 2022
2 parents 58d8237 + 880668c commit b11a06a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 10 deletions.
36 changes: 28 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

A GitHub action to create [Deployments](https://developer.github.com/v3/repos/deployments/) as part of your GitHub CI workflows.

## Required Permissions

\*\*Important: you must grant your GitHub Actions workflow deployment permissions as shown below. Otherwise, this Action will not work.

```yaml
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest

permissions:
deployments: write

# ...
```

## Example usage

```yaml
Expand All @@ -15,6 +31,9 @@ jobs:

runs-on: ubuntu-latest

permissions:
deployments: write

steps:
- uses: actions/checkout@v1

Expand Down Expand Up @@ -53,10 +72,11 @@ jobs:

## Action outputs

| name | description |
| ---------------- | ------------------------------------------------------ |
| `deployment_id` | The ID of the deployment as returned by the GitHub API |
| `deployment_url` | The URL of the created deployment |
| name | description |
| ----------------- | ---------------------------------------------------------------------- |
| `deployment_id` | The ID of the deployment as returned by the GitHub API |
| `deployment_url` | The URL of the created deployment |
| `environment_url` | The environment URL of the deployment (the same as the input variable) |

## Notes

Expand Down Expand Up @@ -99,18 +119,18 @@ jobs:
uses: chrnorm/deployment-status@v2
with:
token: '${{ github.token }}'
environment-url: http://my-app-url.com
state: 'success'
environment-url: ${{ steps.deployment.outputs.environment_url }}
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
state: 'success'

- name: Update deployment status (failure)
if: failure()
uses: chrnorm/deployment-status@v2
with:
token: '${{ github.token }}'
environment-url: http://my-app-url.com
state: 'failure'
environment-url: ${{ steps.deployment.outputs.environment_url }}
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
state: 'failure'
```
## Breaking changes
Expand Down
3 changes: 2 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ outputs:
description: 'The ID of the created deployment'
deployment_url:
description: 'The URL of the created deployment'

environment_url:
description: 'The environment URL of the deployment'
runs:
using: 'node16'
main: 'dist/index.js'
1 change: 1 addition & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function run() {
yield octokit.rest.repos.createDeploymentStatus(Object.assign(Object.assign({}, context.repo), { deployment_id: deployment.data.id, description, state: initialStatus, log_url: logUrl, environment_url: environmentUrl, auto_inactive: autoInactive }));
core.setOutput('deployment_id', deployment.data.id.toString());
core.setOutput('deployment_url', deployment.data.url);
core.setOutput('environment_url', environmentUrl);
}
catch (error) {
core.error(error);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function run() {
yield octokit.rest.repos.createDeploymentStatus(Object.assign(Object.assign({}, context.repo), { deployment_id: deployment.data.id, description, state: initialStatus, log_url: logUrl, environment_url: environmentUrl, auto_inactive: autoInactive }));
core.setOutput('deployment_id', deployment.data.id.toString());
core.setOutput('deployment_url', deployment.data.url);
core.setOutput('environment_url', environmentUrl);
}
catch (error) {
core.error(error);
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ async function run(): Promise<void> {

core.setOutput('deployment_id', deployment.data.id.toString())
core.setOutput('deployment_url', deployment.data.url)
core.setOutput('environment_url', environmentUrl)
} catch (error: any) {
core.error(error)
core.setFailed(`Error creating GitHub deployment: ${error.message}`)
Expand Down

0 comments on commit b11a06a

Please sign in to comment.