Skip to content

Commit

Permalink
add environment_url output variable
Browse files Browse the repository at this point in the history
  • Loading branch information
chrnorm committed May 21, 2022
1 parent 67f9fd6 commit 880668c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,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 @@ -118,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 880668c

Please sign in to comment.