-
Notifications
You must be signed in to change notification settings - Fork 24
167 lines (133 loc) · 3.81 KB
/
CI.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
name: CI
on:
pull_request:
branches: [ master ]
push:
branches: [ master ]
env:
DOCKER_BUILDKIT: "1"
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
show-progress: false
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- run: bun install
- run: bun ci
- run: bun run test
build:
name: Build
runs-on: ubuntu-latest
needs: lint
permissions:
contents: read
packages: write
outputs:
image-tag: ${{ steps.tag.outputs.first }}
image-digest: ${{ steps.build.outputs.digest }}
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/nulldev/csz-bot
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Extract tag
id: tag
env:
INPUT_TAGS: ${{ steps.meta.outputs.tags }}
run: |
first=$(echo "$INPUT_TAGS" | head -n 1)
echo "first=$first" >> "$GITHUB_OUTPUT"
- name: Build and export
uses: docker/build-push-action@v6
id: build
with:
push: ${{ !github.event.repository.fork }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
RELEASE_IDENTIFIER=${{ github.sha }}
BUILD_NUMBER=${{ github.run_number }}
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
deploy-e2e:
name: Deploy e2e
runs-on: ubuntu-latest
if: ${{ !github.event.repository.fork }}
needs: [ build ]
concurrency: e2e
environment:
name: e2e
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- name: Update configuration
env:
BOT_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
CLIENT_ID: ${{ secrets.CI_CLIENT_ID }}
run: |
envsubst < .github/config.json > config.json
- name: Read config.json
id: config
uses: juliangruber/read-file-action@v1
with:
path: ./config.json
- name: Build args
id: args
env:
DRY_RUN: ${{ github.ref == 'refs/heads/master' }}
run: |
args=""
if [[ $DRY_RUN = true ]]; then
args="--dry-run"
fi
echo "args=$args" >> "$GITHUB_OUTPUT"
- name: Deploy CSZ Bot
uses: appleboy/ssh-action@25ce8cbbcb08177468c7ff7ec5cbfa236f9341e1
env:
BOT_HOME_PATH: /home/csc
EPHEMERAL_BOT_CONFIG: ${{ steps.config.outputs.content }}
BOT_ARGS: ${{ steps.args.outputs.args }}
BOT_IMAGE: ${{ needs.build.outputs.image-tag }}
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
envs: BOT_HOME_PATH,EPHEMERAL_BOT_CONFIG,BOT_ARGS,BOT_IMAGE
script: ${{ env.BOT_HOME_PATH }}/.infra/deploy-ephemeral.sh
- name: Comment PR
uses: thollander/actions-comment-pull-request@v3
if: ${{ github.event_name == 'pull_request' }}
with:
comment-tag: discord-invite
message: |
Hallo, hier kannst du jetzt deine tolle neue Funktion testen: https://discord.gg/pJjfF6n2ec