-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (70 loc) · 2.15 KB
/
build-and-deploy.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
name: Build and Deploy
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11
- name: Setup Nix build cache
uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Check Nix flake inputs
uses: DeterminateSystems/flake-checker-action@v7
- name: Build Kubernetes cluster
run: nix build .#kubernetes
- name: Upload cluster artifact
uses: actions/upload-artifact@v4
with:
name: cluster
path: result/
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout cluster branch
uses: actions/checkout@v4
with:
ref: cluster
- name: Remove old files
run: git rm -r .
- name: Download cluster artifact
uses: actions/download-artifact@v4
with:
name: cluster
- name: Create commit message
id: commit-msg
uses: actions/github-script@v7
env:
COMMITS: ${{ toJSON(github.event.commits) }}
with:
result-encoding: string
script: |
const commits = JSON.parse(process.env.COMMITS);
const lines = [];
for (const commit of commits) {
lines.push(`${commit.id.substring(0, 7)} ${commit.message.split("\n")[0]}`);
}
if (lines.length == 1) {
return `[rebuild] ${lines[0]}`;
}
const body = lines.reverse().map(x => `- ${x}`).join('\n\n');
return `[rebuild] ${lines.length} commits\n\n${body}`;
- name: Commit and push
env:
COMMIT_MSG: ${{ steps.commit-msg.outputs.result }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "$COMMIT_MSG" --allow-empty
git push