-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (42 loc) · 1.61 KB
/
main.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
name: Minimize and Publish
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
- name: Install dependencies
run: npm install
- name: Build project
run: npm run build
- name: Install AWS CLI
run: sudo apt-get install awscli -y
- name: Upload /assets/ files to DigitalOcean Space root
env:
DO_SPACES_KEY: ${{ secrets.DO_SPACES_KEY }}
DO_SPACES_SECRET: ${{ secrets.DO_SPACES_SECRET }}
SPACE_NAME: cdn.reallygreatads.com
SPACE_REGION: sfo3
run: |
aws configure set aws_access_key_id $DO_SPACES_KEY
aws configure set aws_secret_access_key $DO_SPACES_SECRET
aws s3 cp dist/assets/ s3://${SPACE_NAME}/ --recursive --region ${SPACE_REGION} --endpoint https://${SPACE_REGION}.digitaloceanspaces.com --acl public-read
- name: Install DigitalOcean CLI
run: |
curl -sL https://github.com/digitalocean/doctl/releases/download/v1.91.0/doctl-1.91.0-linux-amd64.tar.gz | tar -xzv
sudo mv doctl /usr/local/bin
- name: Purge Cache for files in root
env:
DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DO_ACCESS_TOKEN }}
run: |
CDN_ID=$(doctl compute cdn list --no-header --format ID)
FILES_TO_PURGE=$(aws s3 ls s3://${SPACE_NAME}/ --recursive | awk '{print $4}')
for file in $FILES_TO_PURGE; do
doctl compute cdn flush $CDN_ID --files /$file
done