-
Notifications
You must be signed in to change notification settings - Fork 24
174 lines (144 loc) · 4.39 KB
/
CI.yaml
File metadata and controls
174 lines (144 loc) · 4.39 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: CI
on:
pull_request:
branches: [master]
push:
branches: [master]
env:
DOCKER_BUILDKIT: "1"
jobs:
lint:
strategy:
fail-fast: false
matrix:
platform: ["ubuntu-slim", "windows-latest", "macos-latest"]
name: Lint
runs-on: ${{ matrix.platform }}
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v6
with:
show-progress: false
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version: 25.x
cache: npm
- run: npm ci
env:
YOUTUBE_DL_SKIP_DOWNLOAD: true
- run: npm run ci
- run: npm 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@v6
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:
# context needed, so we use path context instead of git context, so .dockerignore is respected
context: "."
push: ${{ !github.event.repository.fork }}
pull: true
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@v6
with:
show-progress: false
- name: Update configuration
env:
DISCORD_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
DISCORD_CLIENT_ID: ${{ secrets.CI_CLIENT_ID }}
PR_ID: ${{ github.event.number }}
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@0ff4204d59e8e51228ff73bce53f80d53301dee2
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