-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
69 lines (65 loc) · 2.39 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: "Deploy DSK"
description: "Deploys Morphcast SDK"
author: "Adapt"
inputs:
aws-region:
description: "AWS region where servers reside"
required: false
default: "eu-west-1"
bucket:
description: "Name of the S3 bucket to deploy to"
required: true
directories-to-deploy:
description: "List of directories to deploy"
required: false
files-to-deploy:
description: "List of files to deploy"
required: false
prefix:
description: "S3 bucket key prefix for files to deploy (e.g. 'my-app/')"
required: false
default: ""
release:
description: "Semantic versioning for release to deploy"
required: true
role-to-assume:
description: "ARN of the role to assume for deployment"
required: true
runs:
using: "composite"
steps:
- name: Configure AWS OIDC credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ inputs.role-to-assume }}
aws-region: ${{ inputs.aws-region }}
role-session-name: DeploySDKCD
- name: Upload artefact
shell: bash
run: |
IFS=' ' read -r -a FILES_OR_PATTERNS <<< "$FILES_TO_DEPLOY"
IFS=' ' read -r -a DIRECTORIES <<< "$DIRECTORIES_TO_DEPLOY"
# Loop through files/patterns and upload each to S3
for pattern in "${FILES_OR_PATTERNS[@]}"; do
if [ -d "$pattern" ]; then
echo "$pattern is a directory, skipping..."
else
aws s3 cp "$pattern" "s3://$S3_BUCKET_NAME/$RELEASE/${PREFIX:-}"
fi
done
# Loop through directories and upload contents to S3 root
for dir in "${DIRECTORIES[@]}"; do
# Find all files within the directory, maintaining subdirectory structure but not the root directory name
while IFS= read -r -d '' file; do
# Extract the path relative to the directory being processed
relative_path="${file#$dir/}"
# Upload the file, preserving subdirectories if any, but not the root directory name
aws s3 cp "$file" "s3://$S3_BUCKET_NAME/$RELEASE/${PREFIX:-}$relative_path"
done < <(find "$dir" -type f -print0)
done
env:
RELEASE: ${{ inputs.release }}
PREFIX: ${{ inputs.prefix }}
FILES_TO_DEPLOY: ${{ inputs.files-to-deploy }}
DIRECTORIES_TO_DEPLOY: ${{ inputs.directories-to-deploy }}
S3_BUCKET_NAME: ${{ inputs.bucket }}