forked from trustwallet/assets
-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (51 loc) · 1.81 KB
/
upload-s3.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
name: Upload S3
on:
push:
branches:
- master
workflow_dispatch:
inputs:
use-size-only:
description: 'Include --size-only flag in aws s3 sync command'
required: false
default: 'true'
permissions:
id-token: write
env:
AWS_REGION: us-east-1
jobs:
upload-s3:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Confiugre AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ env.AWS_REGION }}
- name: Sync to S3
if: github.repository_owner == 'trustwallet'
shell: bash
run: |
SYNC_OPTIONS="--follow-symlinks --delete --exclude '*' --include 'dapps/*' --include 'blockchains/*'"
if [ "${{ github.event.inputs.use-size-only }}" == "true" ]; then
SYNC_OPTIONS="$SYNC_OPTIONS --size-only"
fi
eval "aws s3 sync . s3://$AWS_S3_BUCKET $SYNC_OPTIONS"
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
- name: Get changed files
uses: jitterbit/get-changed-files@v1
if: github.event_name == 'push'
id: files
- name: Filter files to invalidate
run: |
echo "::set-output name=paths::$(echo ${{ steps.files.outputs.added_modified }} | tr ' ' '\n' | grep -E 'blockchains/|dapps/' | awk '{print "/"$1}' | tr '\n' ' ')"
if: github.event_name == 'push'
id: filter
- name: Invalidate CloudFront
if: github.repository_owner == 'trustwallet' && github.event_name == 'push' && steps.filter.outputs.paths != ''
uses: chetan/invalidate-cloudfront-action@v2
env:
PATHS: ${{ steps.filter.outputs.paths }}
DISTRIBUTION: ${{ secrets.AWS_DISTRIBUTION }}