Skip to content

Commit

Permalink
chore: Add an action to test
Browse files Browse the repository at this point in the history
  • Loading branch information
riosje committed May 23, 2024
1 parent 0386425 commit febe47b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/testAction.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on: [push]

jobs:
test_action_job:
runs-on: ubuntu-latest
name: Run AWS Eco Runner
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Execute Action Start
uses: ./
with:
instances_id: '["i-048cc57d9aba24d87"]'
action: "start"

- name: Execute Action Stop
uses: ./
with:
instances_id: '["i-048cc57d9aba24d87"]'
action: "STOP"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ This is an example IAM policy, you must adapt it to yourt needs.
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": ["ec2:StartInstances", "ec2:StopInstances"],
"Resource": "arn:aws:ec2:*:*:instance/$INSTANCE_ID"
"Resource": ["arn:aws:ec2:${REGION}:${ACCOUNT_ID}:instance/${INSTANCE_ID}"]
}
]
}
Expand Down
4 changes: 3 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export async function run() {
try {
//console.log(await start(["i-03f65f60fa8de5492", "i-048cc57d9aba24d87"]));
const instances_id = JSON.parse(core.getInput('instances_id', {required: true}))
const action = core.getInput('action', {required: true})
const action = (core.getInput('action', {required: true})).toLowerCase

if (action === "start") {
await start(instances_id);
Expand All @@ -17,6 +17,8 @@ export async function run() {
return
}

core.setFailed("Invalid action. Please use 'start' or 'stop'");

} catch (err) {
core.setFailed(err);
}
Expand Down

0 comments on commit febe47b

Please sign in to comment.