Skip to content

Workflow file for this run

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
with:
node-version: '20'
- name: Install dependencies
run: npm install uglify-js -g
- name: Verify script.js exists
run: ls -la script.js
- name: Minimize JavaScript
run: uglifyjs script.js -o script.min.js
- name: Verify script.min.js created
run: ls -la script.min.js
- name: Install AWS CLI
run: sudo apt-get install awscli -y
- name: Upload to DigitalOcean Spaces
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 script.min.js s3://${SPACE_NAME}/ --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: List CDN Endpoints
env:
DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DO_ACCESS_TOKEN }}
id: list-cdn
run: |
doctl compute cdn list
- name: Purge Cache
env:
DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DO_ACCESS_TOKEN }}
run: |
CDN_ID=$(doctl compute cdn list --no-header --format ID)
doctl compute cdn flush $CDN_ID --files /script.min.js