Skip to content

Commit

Permalink
Init Repo
Browse files Browse the repository at this point in the history
  • Loading branch information
scottclk committed Apr 26, 2022
0 parents commit cb9e3ce
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Container image
FROM ruby:3.1.1

COPY . /usr/src/app

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"]
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org' do
gem 'aws-sdk-states'
end
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright 2019 Amazon.com, Inc. or its affiliates.

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:

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.
Empty file added README.md
Empty file.
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# action.yml
name: 'StepFunction Deployment Monitoring'
description: 'Polls a step function until completion.'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.STEP_FUNCTION_ARN }}
38 changes: 38 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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
exit 1
end

def get_deployment(execution_arn)
aws_client = Aws::States::Client.new(region: 'eu-west-1')
aws_client.describe_execution({ execution_arn: execution_arn })
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'
end

if %w[FAILED TIMED_OUT ABORTED].include?(deployment_status)
puts "Deployment Failed: #{deployment_status} ❌"
exit 1
elsif deployment_status == 'SUCCEEDED'
puts 'Deployment Successful 🎉'
exit 0
end
2 changes: 2 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
ruby /usr/src/app/app.rb $STEP_FUNCTION_ARN

0 comments on commit cb9e3ce

Please sign in to comment.