Skip to content

Commit b55dbb2

Browse files
committed
Automate S3 staticfiles creation
1 parent ca650b0 commit b55dbb2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
release:
55
types:
66
- created
7-
# branches: [ master ]
87

98
jobs:
109

@@ -23,3 +22,9 @@ jobs:
2322

2423
- name: Push Image to AWS Regristry
2524
run: docker push 949266541515.dkr.ecr.eu-west-1.amazonaws.com/ci-hackathon-app:${GITHUB_REF##*/}
25+
26+
- name: Extract staticfiles folder from image
27+
run: ./extract_staticfiles.sh ${GITHUB_REF##*/}
28+
29+
- name: Push staticfiles to S3
30+
run: AWS_DEFAULT_REGION=eu-west-1 AWS_ACCESS_KEY_ID=${{secrets.AWS_ACCESS_KEY}} AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} aws s3 cp --recursive --acl public-read static s3://codeinstitute-webpublic/hackathon_staticfiles/${GITHUB_REF##*/}

extract_staticfiles.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
rm -fr static
4+
5+
container_id=$(docker create 949266541515.dkr.ecr.eu-west-1.amazonaws.com/ci-hackathon-app:$1)
6+
docker cp $container_id:/static ./static
7+
docker rm -v $container_id
8+

0 commit comments

Comments
 (0)