-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: 'Get Droplet IPs' | ||
description: 'Get the IPs to deploy to using tags' | ||
inputs: | ||
digital-ocean-key: | ||
description: 'The API KEY for DO' | ||
required: true | ||
tags: | ||
description: The tags of the servers | ||
required: true | ||
|
||
outputs: | ||
server_ips: # id of output | ||
description: 'The IPs that match the provided tags' | ||
runs: | ||
using: 'node16' | ||
main: 'index.js' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const core = require('@actions/core'); | ||
const digitalocean = require('digitalocean'); | ||
|
||
try { | ||
// `who-to-greet` input defined in action metadata file | ||
const apiKey = core.getInput('digital-ocean-key'); | ||
const tags = core.getInput('tags'); | ||
const client = digitalocean.client(apiKey); | ||
|
||
console.log(`Fetching droplets for tags ${JSON.stringify(tags)}`); | ||
|
||
client.droplets | ||
.list() | ||
.then((drops) => { | ||
return drops.filter((d) => d.tags.some((dtag) => tags.includes(dtag))); | ||
}) | ||
.then((drops) => { | ||
console.log(`Found ${drops.length} matching droplets`); | ||
return drops.map((d) => d[0].networks.v4[0].ip_address); | ||
}) | ||
.then((ips) => { | ||
core.setOutput('server_ips', ips || []); | ||
}) | ||
.catch((err) => { | ||
core.setFailed(err.message); | ||
}); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.