-
Notifications
You must be signed in to change notification settings - Fork 3
64 lines (63 loc) · 2.21 KB
/
aws-upload.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
name: Reusable AWS upload workflow
on:
workflow_call:
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
AWS_S3_CODE_BUCKET:
required: true
inputs:
image-tag:
description: >
An optional value to write into an image_tags file
before zipping and uploading the repo contents. The
image_tags file is used in some downstream Docker image
builds to tag the image with arbitrary values.
required: false
type: string
default: 'no-tags'
zip-file-name-root:
description: >
An optional value to use as the name of the zip file
uploaded to AWS S3. For example, the value myLovelyRepo
results in myLovelyRepo.zip being uploaded to S3. Where
no value is passed, the zip file will be <exact-repo-name>.zip
required: false
type: string
default: 'repo-name'
jobs:
upload-to-aws:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Create release name
if: github.ref != 'refs/heads/main'
run: |
release_name=`echo ${{ github.actor }}-${{ github.ref_name }}`
echo "Release name: $release_name"
echo $release_name > release_name
- name: Add optional image tags
if: inputs.image-tag != 'no-tags'
run: |
echo "Making an image_tags file with tag value: ${{ inputs.image-tag }}"
echo ${{ inputs.image-tag }} > image_tags
- name: Zip release
run: |
echo ${{ github.sha }} > release
zip -r app.zip .
- name: Push zip to S3
run: |
zip_file_name=${{ inputs.zip-file-name-root }}
if [ "$zip_file_name" = "repo-name" ]; then
echo "Using the default name for the zip file"
zip_file_name="${{ github.event.repository.name }}"
fi
aws s3 cp app.zip "s3://${{ secrets.AWS_S3_CODE_BUCKET }}/$zip_file_name.zip"