This repository has been archived by the owner on Jul 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (153 loc) · 5.21 KB
/
core.yaml
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
name: Core Deployment
on:
workflow_dispatch:
inputs:
bump_type:
description: 'Version Bump Type'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch
- prepatch
- preminor
- premajor
- prerelease
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
repository: cnstr/core
ref: main
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN }}
- name: Configure Caching
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: cnstr-core-buildx-${{ github.sha }}
restore-keys: |
cnstr-core-buildx-
- name: Configure Rust and Cargo
uses: dtolnay/rust-toolchain@stable
- name: Configure Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Configure PNPM and install dependencies
uses: pnpm/action-setup@v2
with:
version: 8
run_install: |
- args: [--frozen-lockfile]
- name: Configure Docker
uses: docker/setup-buildx-action@v2
with:
version: latest
platforms: linux/amd64
- name: Login to tale.me
uses: docker/login-action@v2
with:
registry: us-east4-docker.pkg.dev
username: _json_key_base64
password: ${{ secrets.SERVICE_ACCOUNT }}
- name: Update npm versions and set build-time variables
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
pnpm np --no-cleanup --no-tests --no-publish --no-release-draft --yolo --message 'chore: v%s' $BUMP_TYPE
echo "git_version=$(jq -r '.version' package.json)" >> $GITHUB_ENV
echo "git_state=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "build_date=$(date --rfc-3339=date)" >> $GITHUB_ENV
env:
BUMP_TYPE: ${{ inputs.bump_type }}
- name: Load manifest.yaml for Core
run: echo "$MANIFEST_BASE64" | base64 -d > manifest.yaml
env:
MANIFEST_BASE64: ${{ secrets.CORE_MANIFEST }}
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Configure Docker
uses: docker/setup-buildx-action@v2
with:
version: latest
platforms: linux/amd64
- name: Build us-east4-docker.pkg.dev/aarnavtale/canister/core
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: us-east4-docker.pkg.dev/aarnavtale/canister/core:${{ env.git_version }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-to,mode=max
platforms: linux/amd64
build-args: |
BUILD_DATE=${{ env.build_date }}
VERSION=${{ env.git_version }}
GIT_STATE=${{ env.git_state }}
- name: Update Caching Layers
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-to /tmp/.buildx-cache
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
repository: cnstr/core
ref: main
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN }}
- name: Configure Kubernetes
uses: tale/kubectl-action@v1
with:
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
kubectl-version: v1.26.0
- name: Configure Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Configure PNPM and install dependencies
uses: pnpm/action-setup@v2
with:
version: 8
run_install: |
- args: [--frozen-lockfile]
- name: Retrieve PNPM store path
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Configure Caching
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm--
- name: Load manifest.yaml for Core
run: |
echo "$MANIFEST_BASE64" | base64 -d > manifest.yaml
echo "git_version=$(jq -r '.version' package.json)" >> $GITHUB_ENV
env:
MANIFEST_BASE64: ${{ secrets.CORE_MANIFEST }}
- name: Run deploy tool
run: pnpm run deploy
- name: Commit file changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'chore: update manifests to ${{ env.git_version }}'
commit_author: 'github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>'
commit_options: '--no-verify --signoff'
file_pattern: 'kubernetes/core.yaml kubernetes/fast.yaml'
- name: Deploy Kubernetes manifests
run: kubectl apply -f kubernetes/core.yaml