Skip to content

Commit

Permalink
Handle arrays for deployment_outcome
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisBoudreau committed Feb 21, 2022
1 parent 6b9ca9e commit 4661d3d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 20 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,3 @@ jobs:
yarn
- run: |
yarn all
test: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./
with:
milliseconds: 1000
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ping-slack:
uses: agendrix/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
deployments_outcome: [ ${{ needs.main_deployment.deployment_outcome }} ]
deployments_outcome: ${{ needs.main_deployment.deployment_outcome }}
- name: Ping Slack for outcome
uses: agendrix/slack-notifier/[email protected]
with:
Expand Down
7 changes: 5 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ inputs:
token:
required: true
description: "This should be a personal access token with access to your repository. Ex: ${{ secrets.GITHUB_TOKEN }}"
deployments_outcome:
deployment_outcome:
required: false
description: "Outcome of the deployments. Accepted values are any values from DeploymentOutcome enum: https://github.com/agendrix/wait-for-ecs-service-deployment-action/blob/main/src/ecs/types.ts"
description: >
Outcome of the deployment(s). If you want the action to verify multiple deployments, you must stringify.
Accepted values are any values from DeploymentOutcome enum: https://github.com/agendrix/wait-for-ecs-service-deployment-action/blob/main/src/ecs/types.ts"
Ex: ${{ needs.deploy.deployment_outcome }} or ${{ toJSON([needs.deploy-1.deployment_outcome, needs.deploy-2.deployment_outcome]) }}
outputs:
conclusion:
description: Conclusion of the current workflow run
Expand Down
16 changes: 12 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ async function getJobConclusions() {
);
}

function hasSkippedDeployments() {
let deploymentOutcome = core.getInput("deployments_outcome");
try {
deploymentOutcome = JSON.parse(deploymentOutcome);
return deploymentOutcome.includes(DeploymentOutcome.SKIPPED);
} catch (parsingError) {
return deploymentOutcome === DeploymentOutcome.SKIPPED;
}
}

async function run(): Promise<void> {
try {
validateRequiredInputs([
Expand All @@ -39,11 +49,7 @@ async function run(): Promise<void> {
} else if (jobsConclusion.includes(JobConclusion.CANCELLED)) {
conclusion = WorkflowRunConclusion.STOPPED;
} else {
const deploymentsOutcome = core.getInput("deployments_outcome");
if (
deploymentsOutcome &&
deploymentsOutcome.includes(DeploymentOutcome.SKIPPED)
) {
if (hasSkippedDeployments()) {
conclusion = WorkflowRunConclusion.SKIPPED;
} else {
conclusion = WorkflowRunConclusion.SUCCEEDED;
Expand Down

0 comments on commit 4661d3d

Please sign in to comment.