From a5e497225c587f48cc3ca747f68b63b80c8b7484 Mon Sep 17 00:00:00 2001 From: Scott Clark Date: Wed, 27 Apr 2022 10:55:43 +0100 Subject: [PATCH] First Version --- Dockerfile | 1 - LICENSE | 28 ++++++++++------------------ README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ action.yml | 2 +- app.rb | 25 ++++++------------------- entrypoint.sh | 2 -- 6 files changed, 59 insertions(+), 41 deletions(-) delete mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 1b4b5ad..20f63ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,5 +7,4 @@ RUN cd /usr/src/app && bundle install RUN chmod +x /usr/src/app/entrypoint.sh -# ENTRYPOINT ["/usr/src/app/entrypoint.sh"] ENTRYPOINT ["ruby", "/usr/src/app/app.rb"] \ No newline at end of file diff --git a/LICENSE b/LICENSE index 1f78841..316b331 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,13 @@ -MIT License +Copyright 2021 FreeAgent Central Ltd. -Copyright 2019 Amazon.com, Inc. or its affiliates. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: + http://www.apache.org/licenses/LICENSE-2.0 -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md index e69de29..df56a06 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,42 @@ +# Step Function Deployment Monitoring + +## Description + +GitHub Action used to monitor AWS StepFunction deployments. + +## Usage + +```yaml + - name: Monitor Deploy + id: monitor + uses: fac/sf-deployment-monitoring-action@v1 + with: + EXECUTION_ARN: "" +``` + +## Inputs + +### EXECUTION_ARN + +The StepFunction execution arn that you wish to track the status of. + +## Authors + +* FreeAgent dev-platform opensource@freeagent.com +## Licence + +``` +Copyright 2021 FreeAgent Central Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` diff --git a/action.yml b/action.yml index 21a03fb..2b83118 100644 --- a/action.yml +++ b/action.yml @@ -5,4 +5,4 @@ runs: using: 'docker' image: 'Dockerfile' args: - - ${{ inputs.STEP_FUNCTION_ARN }} + - ${{ inputs.EXECUTION_ARN }} diff --git a/app.rb b/app.rb index b261e79..5294b31 100644 --- a/app.rb +++ b/app.rb @@ -1,36 +1,23 @@ -require 'optparse' require 'aws-sdk-states' -options = {} -option_parser = OptionParser.new do |opts| - opts.banner = 'Usage: app.rb [options]' - opts.on('-e', '--execution-arn ', 'Step Function Execution ARN to monitor') do |v| - options[:execution_arn] = v - end -end - -option_parser.parse! -if options[:execution_arn].nil? - puts 'StepFunction execution arn is required!' - puts option_parser.help +if ENV['EXECUTION_ARN'].nil? + puts 'EXECUTION_ARN is required. Please set it as an ENV Variable.' exit 1 end -def get_deployment(execution_arn) +def deployment_status aws_client = Aws::States::Client.new(region: 'eu-west-1') - aws_client.describe_execution({ execution_arn: execution_arn }) + aws_client.describe_execution({ execution_arn: ENV['EXECUTION_ARN'] }).status end -deployment_status = get_deployment(options[:execution_arn]).status - # One of: "RUNNING", "SUCCEEDED", "FAILED", "TIMED_OUT", "ABORTED" if deployment_status == 'RUNNING' puts 'Deployment in progress...🔄' - sleep 15 until get_deployment(options[:execution_arn]).status != 'RUNNING' + sleep 15 until deployment_status != 'RUNNING' end if %w[FAILED TIMED_OUT ABORTED].include?(deployment_status) - puts "Deployment Failed: #{deployment_status} ❌" + puts "Deployment Failure Status: #{deployment_status} ❌" exit 1 elsif deployment_status == 'SUCCEEDED' puts 'Deployment Successful 🎉' diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100644 index 84e7134..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -ruby /usr/src/app/app.rb $STEP_FUNCTION_ARN