Skip to content

Commit 6570007

Browse files
authored
Merge pull request #5 from aligent/feat/s3-deploy
S3 Deploy Workflow
2 parents 3be2b7b + d86bf61 commit 6570007

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

.github/workflows/s3-deploy.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: S3 Deployment
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
aws-region:
7+
description: "AWS region"
8+
type: string
9+
required: false
10+
default: "ap-southeast-2"
11+
s3-bucket:
12+
description: "Name of the S3 bucket"
13+
type: string
14+
required: true
15+
s3-path:
16+
description: "Path in the S3 bucket"
17+
type: string
18+
required: false
19+
default: ""
20+
local-path:
21+
description: "Path to deploy"
22+
type: string
23+
required: true
24+
default: ""
25+
delete-flag:
26+
description: "Enable --delete flag"
27+
type: boolean
28+
required: false
29+
default: true
30+
cache-control:
31+
description: "Cache control headers"
32+
type: string
33+
required: false
34+
extra-args:
35+
description: "Additional AWS CLI args"
36+
type: string
37+
required: false
38+
default: ""
39+
40+
jobs:
41+
deploy:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
47+
- name: Configure AWS creds
48+
uses: aws-actions/configure-aws-credentials@latest
49+
with:
50+
aws-access-key-id: ${{ secrets.aws-access-key-id }}
51+
aws-secret-access-key: ${{ secrets.aws-secret-access-key }}
52+
aws-region: ${{ inputs.aws-region }}
53+
54+
- name: Deploy to S3
55+
run: |
56+
s3_path=""
57+
cache_control=""
58+
extra_args=""
59+
60+
if [ -n "${{inputs.cache-control}}" ]; then
61+
cache_control="--cache-control \"${{inputs.cache-control}}\""
62+
fi
63+
64+
command="aws s3 sync ${{inputs.local-path}} s3://${{inputs.s3-bucket}}${{inputs.s3-path}} ${cache_control} ${{inputs.extra-args}}"
65+
66+
if [ "${{inputs.delete-flag}}" = "true" ]; then
67+
command="$command --delete"
68+
fi
69+
70+
$command
71+
72+
73+
74+

0 commit comments

Comments
 (0)