-
Notifications
You must be signed in to change notification settings - Fork 5
113 lines (102 loc) · 6.04 KB
/
deploy-cdn.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Deploy to CDN
on:
release:
types: [published]
permissions:
id-token: write # allows the JWT to be requested from GitHub's OIDC provider
contents: read # This is required for actions/checkout
jobs:
deploy-tag:
name: Deploy to PROD
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_PROD_ACCOUNT_ID }}:role/${{ secrets.AWS_PROD_S3_SYNC_ROLE }}
aws-region: us-east-1
- name: Checkout source branch
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Build and sync files to S3
env:
HUSKY: 0
BUGSNAG_API_KEY: ${{ secrets.RS_PROD_BUGSNAG_API_KEY }}
BUGSNAG_RELEASE_STAGE: 'production'
run: |
npm ci
npm run build:browser
npm run build:browser:modern
# for now, skip integrations
# npm run build:integration:all
# npm run build:integration:all:modern
- name: Get new version number
run: |
current_version=$(jq -r .version package.json)
echo "CURRENT_VERSION_VALUE=$current_version" >> $GITHUB_ENV
echo "DATE=$(date)" >> $GITHUB_ENV
- name: Sync files to S3 versioned folder
# for now, skip integrations
# aws s3 cp public/list_integration_sdks.html s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/${{ env.CURRENT_VERSION_VALUE }}/list_integration_sdks.html --cache-control max-age=3600
# aws s3 cp dist/legacy/js-integrations/ s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/${{ env.CURRENT_VERSION_VALUE }}/js-integrations/ --recursive --cache-control max-age=3600
# aws s3 cp public/list_integration_sdks.html s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/${{ env.CURRENT_VERSION_VALUE }}/modern/list_integration_sdks.html --cache-control max-age=3600
# aws s3 cp dist/modern/js-integrations/ s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/${{ env.CURRENT_VERSION_VALUE }}/modern/js-integrations/ --recursive --cache-control max-age=3600
run: |
aws s3 cp dist/legacy/events.min.js s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/v${{ env.CURRENT_VERSION_VALUE }}/events.min.js --cache-control max-age=3600
aws s3 cp dist/legacy/events.min.js.map s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/v${{ env.CURRENT_VERSION_VALUE }}/events.min.js.map --cache-control max-age=3600
aws s3 cp dist/modern/events.min.js s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/v${{ env.CURRENT_VERSION_VALUE }}/modern/events.min.js --cache-control max-age=3600
aws s3 cp dist/modern/events.min.js.map s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/v${{ env.CURRENT_VERSION_VALUE }}/modern/events.min.js.map --cache-control max-age=3600
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_PROD_CF_DISTRIBUTION_ID }} --paths "/js/${{ env.CURRENT_VERSION_VALUE }}*"
- name: Sync files to S3 latest
# for now, skip integrations
# aws s3 cp public/list_integration_sdks.html s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/latest/list_integration_sdks.html --cache-control max-age=3600
# aws s3 cp dist/legacy/js-integrations/ s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/latest/js-integrations/ --recursive --cache-control max-age=3600
# aws s3 cp public/list_integration_sdks.html s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/latest/modern/list_integration_sdks.html --cache-control max-age=3600
# aws s3 cp dist/modern/js-integrations/ s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/latest/modern/js-integrations/ --recursive --cache-control max-age=3600
run: |
aws s3 cp dist/legacy/events.min.js s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/latest/events.min.js --cache-control max-age=3600
aws s3 cp dist/legacy/events.min.js.map s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/latest/events.min.js.map --cache-control max-age=3600
aws s3 cp dist/modern/events.min.js s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/latest/modern/events.min.js --cache-control max-age=3600
aws s3 cp dist/modern/events.min.js.map s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/latest/modern/events.min.js.map --cache-control max-age=3600
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_PROD_CF_DISTRIBUTION_ID }} --paths "/js/latest*"
# for now, skip integrations
# - name: Sync assets to S3
# run: |
# aws s3 cp assets/integrations/AdobeAnalytics/ s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/js/adobe-analytics-js --recursive --cache-control max-age=3600
# aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_PROD_CF_DISTRIBUTION_ID }} --paths "/js/adobe-analytics-js*"
- name: Send message to Slack channel
id: slack
uses: slackapi/[email protected]
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
PROJECT_NAME: 'Events SDK JS - Browser CDN Package'
CDN_URL: 'https://cdn.hightouch-events.com/js/v${{ env.CURRENT_VERSION_VALUE }}/events.min.js'
with:
channel-id: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }}
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "New release: ${{ env.PROJECT_NAME }}"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Release: <${{ env.CDN_URL }}|${{ env.CURRENT_VERSION_VALUE }}>*\n${{ env.DATE }}"
}
}
]
}