Skip to content

Commit

Permalink
First Version
Browse files Browse the repository at this point in the history
  • Loading branch information
scottclk committed Apr 27, 2022
1 parent cb9e3ce commit a5e4972
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 41 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
28 changes: 10 additions & 18 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 [email protected]
## 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.
```
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.STEP_FUNCTION_ARN }}
- ${{ inputs.EXECUTION_ARN }}
25 changes: 6 additions & 19 deletions app.rb
Original file line number Diff line number Diff line change
@@ -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 <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 🎉'
Expand Down
2 changes: 0 additions & 2 deletions entrypoint.sh

This file was deleted.

0 comments on commit a5e4972

Please sign in to comment.