forked from Constructor-io/constructorio-client-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (44 loc) · 2.12 KB
/
publish-cdn.yml
File metadata and controls
54 lines (44 loc) · 2.12 KB
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
name: 'Publish: Publish to CDN'
on:
workflow_call: {}
# It's required to set permissions to be able to:
# - Authenticate to AWS with OIDC
# See: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services
permissions:
id-token: write
contents: read
jobs:
publish-to-cdn:
name: Publish to CDN
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1
with:
role-to-assume: ${{ secrets.AWS_GHA_ROLE }}
role-session-name: constructorio-client-javascript-cdn-publish
aws-region: us-east-1
- name: Copy files to s3
id: copy-files
shell: bash
run: |
# Create a new directory for s3 sync
mkdir s3_dist
# Get the version and copy files
VERSION=$(ls dist/constructorio-client-javascript-*.js | sed 's/.*javascript-\(.*\)\.js/\1/')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
# Copy the bundled file with version number
cp dist/constructorio-client-javascript-$VERSION.js s3_dist/$VERSION.js
# Also create a latest version for easy access
cp dist/constructorio-client-javascript-$VERSION.js s3_dist/latest.js
# Sync to S3 with appropriate caching and permissions
aws s3 sync s3_dist s3://constructor-frontend-prod/sdk/client-javascript --cache-control 'public, max-age=31536000, immutable' --acl 'public-read'
- name: Notify Slack about new publish to CDN
uses: ravsamhq/notify-slack-action@bca2d7f5660b833a27bda4f6b8bef389ebfefd25 # v2.3.0
with:
notification_title: "☁️ New constructorio-client-javascript release published to CDN at version ${{ steps.copy-files.outputs.version }}"
status: ${{ job.status }}
footer: "CDN URL: https://cdn.cnstrc.com/sdk/client-javascript/${{ steps.copy-files.outputs.version }}.js"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}