-
Notifications
You must be signed in to change notification settings - Fork 15
179 lines (161 loc) · 7.01 KB
/
compile-and-publish.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Publish packages
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'lerna.json'
# Test the workflow on pull requests
pull_request:
branches:
- main
permissions:
id-token: write
contents: read
env:
CDN_BUCKET: gc-design-system-production-cdn
CDN_REGION: ca-central-1
jobs:
publish-web:
name: Publish @cdssnc/gcds-components
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: "@cdssnc/gcds-components"
package: "./packages/web"
dist: "./packages/web"
steps:
- name: Git Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Node
uses: actions/setup-node@d86ebcd40b3cb50b156bfa44dd277faf38282d12
with:
node-version: 18
- name: Install ${{ matrix.name }}
run: npm install
- name: Build ${{ matrix.name }}
run: npm run build
# - name: Publish ${{ matrix.name }}
# uses: JS-DevTools/npm-publish@fe58a596e87f1297b15f580ec0dbc833d51a4622
# id: publish
# with:
# token: ${{ secrets.NPM_TOKEN }}
# package: ${{ matrix.dist }}
#
# - name: Configure AWS credentials using OIDC
# if: steps.publish.outputs.id != ''
# uses: aws-actions/configure-aws-credentials@50ac8dd1e1b10d09dac7b8727528b91bed831ac0 # v3.0.2
# with:
# role-to-assume: arn:aws:iam::307395567143:role/gcds-components-apply
# role-session-name: CDNPublish
# aws-region: ${{ env.CDN_REGION }}
- name: Update CDN ${{ matrix.name }} - test
# if: steps.publish.outputs.id != ''
run: |
PUBLISHED_PACKAGE="gcds-components@latest"
# PUBLISHED_PACKAGE="${{ steps.publish.outputs.id }}"
#
mkdir -p ./tmp \
&& sleep 60 \
&& npm install --prefix ./tmp "$PUBLISHED_PACKAGE" \
&& cd ./tmp/node_modules
#
# aws s3 sync ./${{ matrix.name }} s3://${{ env.CDN_BUCKET }}/"$PUBLISHED_PACKAGE" --delete
# aws s3 sync ./${{ matrix.name }} s3://${{ env.CDN_BUCKET }}/${{ matrix.name }}@latest --delete
# aws s3api head-object --bucket ${{ env.CDN_BUCKET }} --key "$PUBLISHED_PACKAGE"/package.json
# aws s3api head-object --bucket ${{ env.CDN_BUCKET }} --key ${{ matrix.name }}@latest/package.json
#
# aws cloudfront create-invalidation --distribution-id ${{ secrets.CDN_CLOUDFRONT_DIST_ID }} --paths "/*"
# working-directory: ${{ matrix.package }}
# - name: Report deployment to Sentinel
# if: steps.publish.outputs.id != ''
# uses: cds-snc/sentinel-forward-data-action@main
# with:
# input_data: '{"product": "design-system", "sha": "${{ github.sha }}", "version": "${{steps.publish.outputs.id}}", "repository": "${{ github.repository }}", "environment": "production", "status": "${{ job.status }}"}'
# log_type: CDS_Product_Deployment_Data
# log_analytics_workspace_id: ${{ secrets.LOG_ANALYTICS_WORKSPACE_ID }}
# log_analytics_workspace_key: ${{ secrets.LOG_ANALYTICS_WORKSPACE_KEY }}
#
#
# - name: Slack notify on failure
# if: failure()
# run: |
# json='{"blocks":[{"type":"section","text":{"type":"mrkdwn","text":":red: Publish ${{ matrix.name }} failed: <https://github.com/cds-snc/gcds-components/actions/workflows/compile-and-publish.yml|Publish packages>"}}]}'
# curl -X POST -H 'Content-type: application/json' --data "$json" ${{ secrets.SLACK_WEBHOOK_OPS }}
publish-react-angular:
name: Publish @cdssnc/gcds-components-react and @cdssnc/gcds-components-angular
needs: publish-web
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: "@cdssnc/gcds-components-react"
package: "./packages/react"
dist: "./packages/react"
cdn: "gcds-components-react"
- name: "@cdssnc/gcds-components-angular"
package: "./packages/angular"
dist: "./packages/angular/dist"
cdn: "gcds-components-angular"
steps:
- name: Git Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Node
uses: actions/setup-node@d86ebcd40b3cb50b156bfa44dd277faf38282d12
with:
node-version: 18
- name: Install monorepo
run: npm install
- name: Build gcds-components
run: npm run build
# - name: Publish ${{ matrix.name }}
# uses: JS-DevTools/npm-publish@fe58a596e87f1297b15f580ec0dbc833d51a4622
# id: publish
# with:
# token: ${{ secrets.NPM_TOKEN }}
# package: ${{ matrix.dist }}
#
# - name: Configure AWS credentials using OIDC
# if: steps.publish.outputs.id != ''
# uses: aws-actions/configure-aws-credentials@50ac8dd1e1b10d09dac7b8727528b91bed831ac0 # v3.0.2
# with:
# role-to-assume: arn:aws:iam::307395567143:role/gcds-components-apply
# role-session-name: CDNPublish
# aws-region: ${{ env.CDN_REGION }}
#
- name: Update CDN ${{ matrix.name }} - test
# if: steps.publish.outputs.id != ''
run: |
PUBLISHED_PACKAGE="${{ matrix.cdn }}@latest"
# PUBLISHED_PACKAGE="${{ steps.publish.outputs.id }}"
#
mkdir -p ./tmp \
&& npm install --prefix ./tmp "$PUBLISHED_PACKAGE" \
&& cd ./tmp/node_modules
#
# aws s3 sync ./${{ matrix.name }} s3://${{ env.CDN_BUCKET }}/"$PUBLISHED_PACKAGE" --delete
# aws s3 sync ./${{ matrix.name }} s3://${{ env.CDN_BUCKET }}/${{ matrix.name }}@latest --delete
# aws s3api head-object --bucket ${{ env.CDN_BUCKET }} --key "$PUBLISHED_PACKAGE"/package.json
# aws s3api head-object --bucket ${{ env.CDN_BUCKET }} --key ${{ matrix.name }}@latest/package.json
#
# aws cloudfront create-invalidation --distribution-id ${{ secrets.CDN_CLOUDFRONT_DIST_ID }} --paths "/*"
# working-directory: ${{ matrix.package }}
#
# - name: Report deployment to Sentinel
# if: steps.publish.outputs.id != ''
# uses: cds-snc/sentinel-forward-data-action@main
# with:
# input_data: '{"product": "design-system", "sha": "${{ github.sha }}", "version": "${{steps.publish.outputs.id}}", "repository": "${{ github.repository }}", "environment": "production", "status": "${{ job.status }}"}'
# log_type: CDS_Product_Deployment_Data
# log_analytics_workspace_id: ${{ secrets.LOG_ANALYTICS_WORKSPACE_ID }}
# log_analytics_workspace_key: ${{ secrets.LOG_ANALYTICS_WORKSPACE_KEY }}
#
# - name: Slack notify on failure
# if: failure()
# run: |
# json='{"blocks":[{"type":"section","text":{"type":"mrkdwn","text":":red: Publish ${{ matrix.name }} failed: <https://github.com/cds-snc/gcds-components/actions/workflows/compile-and-publish.yml|Publish packages>"}}]}'
# curl -X POST -H 'Content-type: application/json' --data "$json" ${{ secrets.SLACK_WEBHOOK_OPS }}