-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
73 lines (66 loc) · 2.4 KB
/
action.yaml
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
70
71
72
73
name: Frontend deploy action
description: 'downloads artifact and deploys to AWS s3'
inputs:
AWS_ACCESS_KEY_ID:
description: 'AWS_ACCESS_KEY_ID secret'
required: true
AWS_SECRET_ACCESS_KEY:
description: 'AWS_SECRET_ACCESS_KEY secret'
required: true
bucket_name:
description: 'build.outputs.bucket_name'
required: true
SLACK_TOKEN:
description: 'slack token'
required: false
default: ''
SLACK_CHANNEL:
description: 'slack channel'
required: false
default: ''
runs:
using: 'composite'
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: build_result
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ inputs.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ inputs.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- name: Deploy to AWS
run: |
aws configure set default.s3.max_concurrent_requests 50
aws s3 rm s3://ec-admins/${{ inputs.bucket_name }} --recursive
aws s3 sync ./ s3://ec-admins/${{ inputs.bucket_name }} --cache-control max-age=31536000 --exclude "index.html"
aws s3 sync ./ s3://ec-admins/${{ inputs.bucket_name }} --cache-control max-age=0 --exclude "*" --include "index.html"
shell: bash
- name: check if bucket_name is prod
if: inputs.SLACK_TOKEN != '' && inputs.SLACK_CHANNEL != ''
id: check-bucket_name-tag
run: |
if [[ ${{ inputs.bucket_name }} == *-prod ]]; then
echo "match=true" >> $GITHUB_OUTPUT
fi
shell: bash
- name: trim bucket_name
if: steps.check-bucket_name-tag.outputs.match == 'true'
run: |
app_name_trimmed=$(echo ${{ inputs.bucket_name }} | awk -F '-' '{OFS="-"; $NF=""; print $0}' | sed 's/-$//')
echo "APP_NAME=$app_name_trimmed" >> $GITHUB_ENV
shell: bash
- name: Hector slack Notifications
if: steps.check-bucket_name-tag.outputs.match == 'true' && inputs.SLACK_TOKEN != '' && inputs.SLACK_CHANNEL != ''
uses: slackapi/slack-github-action@v2
with:
method: chat.postMessage
token: ${{ inputs.SLACK_TOKEN }}
payload: |
channel: ${{ inputs.SLACK_CHANNEL }}
attachments:
- color: "28a745"
fields:
- value: "Neue Version von ${{ env.APP_NAME }} ausgerollt"