-
-
Notifications
You must be signed in to change notification settings - Fork 184
155 lines (135 loc) · 5.31 KB
/
Copy pathplatform-build.yml
File metadata and controls
155 lines (135 loc) · 5.31 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
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
name: platform-build
on:
push:
branches: ["karrio-platform"]
workflow_dispatch:
jobs:
changes:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.changes.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
version:
- 'apps/api/karrio/server/VERSION'
platform-server-build:
needs: changes
if: ${{ needs.changes.outputs.version == 'true' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
version: ${{ steps.get_tag.outputs.tag }}
env:
DOCKER_BUILDKIT: 1
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GH_PAT }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- id: get_tag
run: |
echo "tag=$(cat ./apps/api/karrio/server/VERSION)" >> "$GITHUB_OUTPUT"
- name: Build JS client
run: |
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate \
-i /local/schemas/openapi.yml \
-g typescript-fetch \
-o /local/packages/karriojs/api/generated \
--additional-properties=typescriptThreePlus=true \
--additional-properties=modelPropertyNaming=snake_case \
--additional-properties=useSingleRequestParameter=true
cd packages/karriojs
npm ci
npx gulp build --output "${GITHUB_WORKSPACE}/apps/api/karrio/server/static/karrio/js/karrio.js"
cd -
- name: Build embeddable elements
run: |
cd packages/elements
npm ci
npm run build
ELEMENTS_STATIC="${GITHUB_WORKSPACE}/apps/api/karrio/server/static/karrio/elements"
mkdir -p "${ELEMENTS_STATIC}" "${ELEMENTS_STATIC}/chunks"
cp dist/elements.js dist/globals.css "${ELEMENTS_STATIC}/"
cp dist/ratesheet.js dist/ratesheet.html "${ELEMENTS_STATIC}/"
cp dist/devtools.js dist/devtools.css dist/devtools.html "${ELEMENTS_STATIC}/"
cp dist/template-editor.js dist/template-editor.html "${ELEMENTS_STATIC}/"
cp dist/connections.js dist/connections.html "${ELEMENTS_STATIC}/"
[ -d dist/chunks ] && cp dist/chunks/* "${ELEMENTS_STATIC}/chunks/"
cd -
- name: Build platform server image
run: |
echo 'Build and push karrio-platform server:${{ steps.get_tag.outputs.tag }}...'
echo ${{ secrets.GH_PAT }} | docker login ghcr.io -u USERNAME --password-stdin
EDITION=platform \
KARRIO_IMAGE=ghcr.io/karrioapi/cloud \
./bin/build-insiders-image ${{ steps.get_tag.outputs.tag }} &&
docker push ghcr.io/karrioapi/cloud:${{ steps.get_tag.outputs.tag }} || exit 1
platform-ecr-publish:
needs: platform-server-build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Pull platform server image
run: |
echo ${{ secrets.GH_PAT }} | docker login ghcr.io -u USERNAME --password-stdin
docker pull ghcr.io/karrioapi/cloud:${{ needs.platform-server-build.outputs.version }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
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: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: true
- name: Tag and push to AWS ECR
run: |
docker tag ghcr.io/karrioapi/cloud:${{ needs.platform-server-build.outputs.version }} 563562701692.dkr.ecr.us-east-1.amazonaws.com/karrio/api:${{ needs.platform-server-build.outputs.version }}
docker push 563562701692.dkr.ecr.us-east-1.amazonaws.com/karrio/api:${{ needs.platform-server-build.outputs.version }}
platform-infra-deploy:
needs: [platform-server-build, platform-ecr-publish]
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GH_PAT }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ca-central-1
- name: Install Pulumi CLI
run: |
curl -fsSL https://get.pulumi.com | sh
export PATH=$PATH:$HOME/.pulumi/bin
echo "$HOME/.pulumi/bin" >> $GITHUB_PATH
- name: Deploy with Pulumi
env:
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
PULUMI_STATE_BUCKET: ${{ secrets.PULUMI_STATE_BUCKET }}
run: |
pulumi login s3://${{ secrets.PULUMI_STATE_BUCKET }}
cd ee/platform/infra && npm install && pulumi up -s karrio-us --skip-preview --yes