Skip to content

Commit

Permalink
Configure Library to be deployed to CDN via Actions (#68)
Browse files Browse the repository at this point in the history
AnalyticsSDK: set up to be deployed via CDN
  • Loading branch information
mtian725 committed Aug 31, 2023
1 parent 5eb21b4 commit 7e0c024
Show file tree
Hide file tree
Showing 7 changed files with 955 additions and 4 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/deploy_hold.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Deploy assets to AWS S3 and GCP Cloud Storage with hold state setup in github's production environment

on:
workflow_call:
inputs:
bucket:
required: false
type: string
default: analytics
directory:
required: true
type: string
cache-control:
required: false
type: string
default: no-cache
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
GCP_SA_KEY:
required: true

jobs:
deploy-aws:
runs-on: ubuntu-latest
environment: production # sets in github repo with reviewer requirement protection rule
steps:
- uses: actions/checkout@v3
- name: Download build-output-US artifact
uses: actions/download-artifact@v3
with:
name: build-output-US
path: dist/
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Deploy to S3
run: |
aws s3 cp ./dist/ s3://assets.sitescdn.net/${{ inputs.bucket }}/${{ inputs.directory }} \
--acl public-read \
--recursive \
--cache-control ${{ inputs.cache-control }}
deploy-gcp:
runs-on: ubuntu-latest
environment: production # sets in github repo with reviewer requirement protection rule
steps:
- uses: actions/checkout@v3
- name: Download build-output-EU artifact
uses: actions/download-artifact@v3
with:
name: build-output-EU
path: dist/
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v1
with:
credentials_json: "${{ secrets.GCP_SA_KEY }}"
- name: Deploy to GCP Bucket
uses: google-github-actions/upload-cloud-storage@v1
with:
path: dist/
parent: false
destination: assets-eu.sitescdn.net/${{ inputs.bucket }}/${{ inputs.directory }}
process_gcloudignore: false
headers: |-
cache-control: ${{ inputs.cache-control }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
coverage/
dist/
lib/
temp/
.env
Expand Down
Loading

0 comments on commit 7e0c024

Please sign in to comment.