-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (126 loc) · 4.29 KB
/
ci.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
name: CI-CD
on:
push:
env:
# Docker
DOCKER_DOMAIN: ghcr.io
DOCKER_USER: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
DOCKER_LATEST_BRANCH: main
DOCKER_CACHE_KEY_ID: ${{ secrets.R2_KEY_ID }}
DOCKER_CACHE_KEY_SECRET: ${{ secrets.R2_KEY_SECRET }}
DOCKER_CACHE_URL: "https://9f21cac25548ad04899fc78c8101e7de.r2.cloudflarestorage.com"
DOCKER_CACHE_BUCKET: "ci-cache"
DOCKER_CACHE_REGION: "APAC"
jobs:
precommit:
name: Pre-commit Check
runs-on:
- nscloud-ubuntu-22.04-amd64-4x8-with-cache
- nscloud-cache-size-50gb
- nscloud-cache-tag-nitroso-helium-nix-store-cache
- nscloud-git-mirror-1gb
steps:
# Setup
- uses: AtomiCloud/actions.setup-nix@v1.2.1
- uses: AtomiCloud/actions.cache-bun@v1.0.1
# Action
- name: Run pre-commit
run: nix develop .#ci -c ./scripts/ci/pre-commit.sh
build:
name: Build Docker
permissions:
contents: read
id-token: write
packages: write
runs-on: ubuntu-22.04
strategy:
matrix:
configs:
- image-name: nitroso-helium
dockerfile: ./infra/Dockerfile
context: .
platform: linux/arm64,linux/amd64
env:
STRAT_DOCKER_IMAGE: ${{ matrix.configs.image-name }}
STRAT_DOCKERFILE: ${{ matrix.configs.dockerfile }}
STRAT_DOCKER_CONTEXT: ${{ matrix.configs.context }}
STRAT_DOCKER_PLATFORM: ${{ matrix.configs.platform }}
steps:
# Setup
- uses: AtomiCloud/actions.setup-docker@v1.2.0
# Action
- uses: rlespinasse/github-slug-action@v3.x
- name: Build and Push Docker
run: ./scripts/ci/ci-docker.sh
env:
CI_DOCKER_IMAGE: ${{ env.STRAT_DOCKER_IMAGE }}
CI_DOCKER_CONTEXT: ${{ env.STRAT_DOCKER_CONTEXT }}
CI_DOCKERFILE: ${{ env.STRAT_DOCKERFILE }}
CI_DOCKER_PLATFORM: ${{ env.STRAT_DOCKER_PLATFORM }}
DOMAIN: ${{ env.DOCKER_DOMAIN }}
GITHUB_REPO_REF: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_BRANCH: ${{ env.GITHUB_REF_SLUG }}
DOCKER_PASSWORD: ${{ env.DOCKER_PASSWORD }}
DOCKER_USER: ${{ env.DOCKER_USER }}
S3_KEY_ID: ${{ env.DOCKER_CACHE_KEY_ID }}
S3_KEY_SECRET: ${{ env.DOCKER_CACHE_KEY_SECRET }}
S3_URL: ${{ env.DOCKER_CACHE_URL }}
S3_BUCKET: ${{ env.DOCKER_CACHE_BUCKET }}
S3_REGION: ${{ env.DOCKER_CACHE_REGION }}
LATEST_BRANCH: ${{ env.DOCKER_LATEST_BRANCH}}
publish:
name: Publish Helm
needs: build
permissions:
contents: read
id-token: write
packages: write
runs-on:
- nscloud-ubuntu-22.04-amd64-4x8-with-cache
- nscloud-cache-size-50gb
- nscloud-cache-tag-nitroso-helium-nix-store-cache
- nscloud-git-mirror-1gb
steps:
# Setup
- uses: AtomiCloud/actions.setup-nix@v1.2.1
# Action
- uses: rlespinasse/github-slug-action@v3.x
- name: Publish
env:
GITHUB_REPO_REF: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_BRANCH: ${{ env.GITHUB_REF_SLUG_URL }}
DOMAIN: ${{ env.DOCKER_DOMAIN }}
DOCKER_PASSWORD: ${{ env.DOCKER_PASSWORD }}
DOCKER_USER: ${{ env.DOCKER_USER }}
run: nix develop .#ci -c scripts/ci/publish-helm.sh
release:
name: Semantic Release
needs:
- precommit
- build
if: github.ref == 'refs/heads/main'
runs-on:
- nscloud-ubuntu-22.04-amd64-4x8-with-cache
- nscloud-cache-size-50gb
- nscloud-cache-tag-releaser-nitroso-helium-nix-store-cache
- nscloud-git-mirror-1gb
steps:
# Setup
- uses: AtomiCloud/actions.setup-nix@v1.2.1
- uses: AtomiCloud/actions.cache-npm@v1.0.1
# Action
- uses: rlespinasse/github-slug-action@v3.x
- name: Release
env:
GITHUB_REPO_REF: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_BRANCH: ${{ env.GITHUB_REF_SLUG_URL }}
CI_DOCKER_IMAGES: "nitroso-helium"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOMAIN: ${{ env.DOCKER_DOMAIN }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
DOCKER_USER: ${{ env.DOCKER_USER }}
run: nix develop .#releaser -c scripts/ci/release.sh