From d150281810e2e3572d4832d391fd3d31f1f5fcc3 Mon Sep 17 00:00:00 2001
From: Rami <32602478+rlukata@users.noreply.github.com>
Date: Thu, 5 Oct 2023 12:59:57 -0700
Subject: [PATCH] allow env vars

---
 action.yml               | 4 ++--
 src/utils/actionUtils.ts | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/action.yml b/action.yml
index 519821a..b6b7039 100644
--- a/action.yml
+++ b/action.yml
@@ -19,10 +19,10 @@ inputs:
     required: true
   aws-access-key-id:
     description: 'An AWS access key id to access the bucket'
-    required: true
+    required: false
   aws-secret-access-key:
     description: 'An AWS secret access key to access the bucket'
-    required: true
+    required: false
   aws-region:
     description: 'An AWS region where the bucket is located'
     required: false
diff --git a/src/utils/actionUtils.ts b/src/utils/actionUtils.ts
index 4a1a659..45a9d9b 100644
--- a/src/utils/actionUtils.ts
+++ b/src/utils/actionUtils.ts
@@ -2,7 +2,7 @@ import * as core from "@actions/core";
 
 import { Inputs, Outputs, RefKey, State } from "../constants";
 
-import {CommonPrefix, InputSerialization, S3ClientConfig} from "@aws-sdk/client-s3";
+import {S3ClientConfig} from "@aws-sdk/client-s3";
 
 export function isGhes(): boolean {
     const ghUrl = new URL(
@@ -85,10 +85,10 @@ export function getInputS3ClientConfig(): S3ClientConfig | undefined {
 
     const s3config = {
         credentials: {
-          accessKeyId: core.getInput(Inputs.AWSAccessKeyId),
-          secretAccessKey: core.getInput(Inputs.AWSSecretAccessKey)
+          accessKeyId: core.getInput(Inputs.AWSAccessKeyId) || process.env['AWS_ACCESS_KEY_ID'],
+          secretAccessKey: core.getInput(Inputs.AWSSecretAccessKey)|| process.env['AWS_SECRET_ACCESS_KEY']
         },
-        region: core.getInput(Inputs.AWSRegion),
+        region: core.getInput(Inputs.AWSRegion) || process.env['AWS_REGION'],
         endpoint: core.getInput(Inputs.AWSEndpoint),
         bucketEndpoint: core.getBooleanInput(Inputs.AWSS3BucketEndpoint),
         forcePathStyle: core.getBooleanInput(Inputs.AWSS3ForcePathStyle),