Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mario-jerkovic committed Jan 2, 2025
2 parents 5379068 + eb4f007 commit 39cb4e9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rimac-technology/semantic-release-ecr",
"version": "2.0.12",
"version": "2.1.0",
"description": "Semantic-release plugin to publish a docker image to the AWS Elastic Container Registry",
"keywords": [
"release",
Expand Down
9 changes: 8 additions & 1 deletion src/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class AWS {
let region: string | null = null
let accessKeyId: string | null = null
let secretAccessKey: string | null = null
let sessionToken: string | null = null

if (context.env.AWS_DEFAULT_REGION) {
region = context.env.AWS_DEFAULT_REGION
Expand All @@ -24,20 +25,26 @@ export class AWS {
secretAccessKey = context.env.AWS_SECRET_ACCESS_KEY
}

if (context.env.AWS_SESSION_TOKEN) {
sessionToken = context.env.AWS_SESSION_TOKEN
}

return {
accessKeyId,
region,
secretAccessKey,
sessionToken
}
}

public readonly awsEcr: InstanceType<typeof ECRClient>

constructor(accessKeyId: string, region: string, secretAccessKey: string) {
constructor(accessKeyId: string, region: string, secretAccessKey: string, sessionToken: string) {
this.awsEcr = new ECRClient({
credentials: {
accessKeyId,
secretAccessKey,
sessionToken
},
region,
})
Expand Down
7 changes: 7 additions & 0 deletions src/aws.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ export type AWSConfigType = {
* @default ""
*/
secretAccessKey: string | null

/**
* (optional) AWS session token for the provided credentials
*
* @default ""
*/
sessionToken: string | null
}

export type AWSLoginValueType = {
Expand Down
2 changes: 1 addition & 1 deletion src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { PluginConfig, WithoutNullableKeysType } from './types.js'

export async function publish(pluginConfig: PluginConfig, context: PublishContext): Promise<void> {
const awsConfig = AWS.loadConfig(context) as WithoutNullableKeysType<AWSConfigType>
const aws = new AWS(awsConfig.accessKeyId, awsConfig.region, awsConfig.secretAccessKey)
const aws = new AWS(awsConfig.accessKeyId, awsConfig.region, awsConfig.secretAccessKey, awsConfig.sessionToken)

const awsLoginValue = await aws.login()

Expand Down

0 comments on commit 39cb4e9

Please sign in to comment.