Skip to content

Commit 4618655

Browse files
authored
GitHub Action to copy static workshop resources to S3 bucket for (#51)
1 parent ef2ac91 commit 4618655

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/copy-to-s3.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
name: Copy to S3
3+
on:
4+
push:
5+
branches:
6+
- main
7+
env:
8+
AWS_DEFAULT_REGION: us-west-2
9+
AWS_DEFAULT_OUTPUT: json
10+
jobs:
11+
copy-to-s3:
12+
runs-on: ubuntu-latest
13+
# These permissions are needed to interact with GitHub’s OIDC Token endpoint.
14+
permissions:
15+
id-token: write
16+
contents: read
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
- name: Setup Java
21+
uses: actions/setup-java@v4
22+
with:
23+
distribution: corretto
24+
java-version: '17'
25+
cache: maven
26+
- name: Configure AWS Credentials
27+
uses: aws-actions/configure-aws-credentials@v2
28+
with:
29+
aws-region: us-west-2
30+
## the following creates an ARN based on the values entered into github secrets
31+
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_GITHUB_ACTIONS_ROLE }}
32+
- name: Build Custom Resources
33+
run: |
34+
cd resources/custom-resources
35+
for CUSTOM_RESOURCE in $(ls -d *)
36+
do
37+
cd $CUSTOM_RESOURCE
38+
mvn
39+
cd ..
40+
done
41+
cd ../../
42+
- name: Copy files to S3
43+
run: |
44+
WORKSHOP_BUCKET=aws-saas-factory-serverless-saas-workshop-us-west-2
45+
for CFT in $(ls resources/*.template)
46+
do
47+
aws s3 cp $CFT "s3://$WORKSHOP_BUCKET/$(basename $CFT)" --acl authenticated-read
48+
done
49+
for CUSTOM_RESOURCE in $(find resources/custom-resources -type f -name '*.jar' ! -name '*original-*.jar')
50+
do
51+
aws s3 cp $CUSTOM_RESOURCE "s3://$WORKSHOP_BUCKET/$(basename $CUSTOM_RESOURCE)" --acl authenticated-read
52+
done
53+
...

0 commit comments

Comments
 (0)