forked from Brightspace/parse-sqs-queue-url-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
22 lines (17 loc) · 671 Bytes
/
index.js
File metadata and controls
22 lines (17 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const core = require( '@actions/core' );
const queueUrlRegex = /^https:\/\/sqs\.(?<region>[a-z0-9-]+).amazonaws\.com\/(?<account>\d+)\/(?<name>.+)$/;
try {
const queueUrl = core.getInput( 'sqs-queue-url' );
if( !queueUrl ) {
core.setFailed( 'Input \'sqs-queue-url\' not set.' );
}
const match = queueUrlRegex.exec( queueUrl );
if( !match ) {
core.setFailed( `Invalid 'sqs-queue-url' input provided: ${queueUrl}` );
}
core.setOutput( 'aws-account-id', match.groups[ 'account' ] );
core.setOutput( 'aws-region', match.groups[ 'region' ] );
core.setOutput( 'sqs-queue-name', match.groups[ 'name' ] );
} catch( error ) {
core.setFailed( error.message );
}