-
-
Notifications
You must be signed in to change notification settings - Fork 16
147 lines (134 loc) · 8.29 KB
/
builder.yml
File metadata and controls
147 lines (134 loc) · 8.29 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
name: Docker Image CI
on:
workflow_dispatch:
push:
branches:
- "**"
paths:
- 'packages/dota/**' # Dota service and related changes
- 'packages/twitch-chat/**' # Twitch Chat service changes
- 'packages/steam/**' # Steam service changes
- 'packages/twitch-events/**' # Twitch Events service changes
- 'packages/shared-utils/**' # Shared utilities used by multiple services
- 'packages/profanity-filter/**'
- 'package.json'
- 'bun.lock'
- 'packages/Dockerfile.bun' # Shared Dockerfile for bun-based services
- 'docker-compose.yml' # Compose file changes might affect all services
jobs:
# Dota job remains separate because it has extra change checks
dota:
runs-on: ubuntu-latest
environment: prod
permissions:
packages: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Check for changes in dota service
id: dota-changes
run: |
git diff --name-only HEAD^ HEAD | grep -q "^packages/profanity-filter/" && echo "profanity_filter_changed=true" >> $GITHUB_OUTPUT || echo "profanity_filter_changed=false" >> $GITHUB_OUTPUT
git diff --name-only HEAD^ HEAD | grep -q "^package.json\|^bun.lock" && echo "deps_changed=true" >> $GITHUB_OUTPUT || echo "deps_changed=false" >> $GITHUB_OUTPUT
git diff --name-only HEAD^ HEAD | grep -q "^packages/dota/" && echo "changed=true" >> $GITHUB_OUTPUT || echo "changed=false" >> $GITHUB_OUTPUT
git diff --name-only HEAD^ HEAD | grep -q "^packages/shared-utils/" && echo "shared_utils_changed=true" >> $GITHUB_OUTPUT || echo "shared_utils_changed=false" >> $GITHUB_OUTPUT
git diff --name-only HEAD^ HEAD | grep -q "^packages/Dockerfile.bun" && echo "dockerfile_changed=true" >> $GITHUB_OUTPUT || echo "dockerfile_changed=false" >> $GITHUB_OUTPUT
git diff --name-only HEAD^ HEAD | grep -q "^docker-compose.yml" && echo "compose_changed=true" >> $GITHUB_OUTPUT || echo "compose_changed=false" >> $GITHUB_OUTPUT
- name: Extract branch name
if: ${{ github.event_name == 'workflow_dispatch' || steps.dota-changes.outputs.changed == 'true' || steps.dota-changes.outputs.dockerfile_changed == 'true' || steps.dota-changes.outputs.compose_changed == 'true' || steps.dota-changes.outputs.deps_changed == 'true' || steps.dota-changes.outputs.profanity_filter_changed == 'true' || steps.dota-changes.outputs.shared_utils_changed == 'true' }}
shell: bash
run: |
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
# Sanitize branch name for Docker tag (replace '/' with '-')
echo "DOCKER_TAG=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g')" >> $GITHUB_ENV
- name: Set up Docker Buildx
if: ${{ github.event_name == 'workflow_dispatch' || steps.dota-changes.outputs.changed == 'true' || steps.dota-changes.outputs.dockerfile_changed == 'true' || steps.dota-changes.outputs.compose_changed == 'true' || steps.dota-changes.outputs.deps_changed == 'true' || steps.dota-changes.outputs.profanity_filter_changed == 'true' || steps.dota-changes.outputs.shared_utils_changed == 'true' }}
uses: docker/setup-buildx-action@v4
with:
driver-opts: |
network=host
image=moby/buildkit:latest
buildkitd-flags: --debug
- name: Login to ghcr
if: ${{ github.event_name == 'workflow_dispatch' || steps.dota-changes.outputs.changed == 'true' || steps.dota-changes.outputs.dockerfile_changed == 'true' || steps.dota-changes.outputs.compose_changed == 'true' || steps.dota-changes.outputs.deps_changed == 'true' || steps.dota-changes.outputs.profanity_filter_changed == 'true' || steps.dota-changes.outputs.shared_utils_changed == 'true' }}
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHA_PAT }}
- name: Build and push
if: ${{ github.event_name == 'workflow_dispatch' || steps.dota-changes.outputs.changed == 'true' || steps.dota-changes.outputs.dockerfile_changed == 'true' || steps.dota-changes.outputs.compose_changed == 'true' || steps.dota-changes.outputs.deps_changed == 'true' || steps.dota-changes.outputs.profanity_filter_changed == 'true' || steps.dota-changes.outputs.shared_utils_changed == 'true' }}
uses: docker/bake-action@v7
with:
push: true
provenance: false
targets: dota
set: |
*.platform=linux/arm64,linux/amd64/v3
dota.tags=ghcr.io/${{ github.repository_owner }}/dota:${{ env.DOCKER_TAG }}
*.cache-from=
*.cache-to=
# Combined job for twitch-chat, steam, and twitch-events using a matrix
services:
runs-on: ubuntu-latest
environment: prod
permissions:
packages: write
strategy:
matrix:
include:
- service: twitch-chat
changed_path: "^packages/twitch-chat/"
dockerfile: "packages/Dockerfile.bun"
- service: steam
changed_path: "^packages/steam/"
dockerfile: "packages/Dockerfile.steam"
- service: twitch-events
changed_path: "^packages/twitch-events/"
dockerfile: "packages/Dockerfile.bun"
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Check for changes in ${{ matrix.service }} service
id: changes
run: |
git diff --name-only HEAD^ HEAD | grep -q "${{ matrix.changed_path }}" && echo "changed=true" >> $GITHUB_OUTPUT || echo "changed=false" >> $GITHUB_OUTPUT
git diff --name-only HEAD^ HEAD | grep -q "^packages/shared-utils/" && echo "shared_utils_changed=true" >> $GITHUB_OUTPUT || echo "shared_utils_changed=false" >> $GITHUB_OUTPUT
git diff --name-only HEAD^ HEAD | grep -q "^${{ matrix.dockerfile }}" && echo "dockerfile_changed=true" >> $GITHUB_OUTPUT || echo "dockerfile_changed=false" >> $GITHUB_OUTPUT
git diff --name-only HEAD^ HEAD | grep -q "^docker-compose.yml" && echo "compose_changed=true" >> $GITHUB_OUTPUT || echo "compose_changed=false" >> $GITHUB_OUTPUT
- name: Extract branch name
if: ${{ github.event_name == 'workflow_dispatch' || steps.changes.outputs.changed == 'true' || steps.changes.outputs.shared_utils_changed == 'true' || steps.changes.outputs.dockerfile_changed == 'true' || steps.changes.outputs.compose_changed == 'true' }}
shell: bash
run: |
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
# Sanitize branch name for Docker tag (replace '/' with '-')
echo "DOCKER_TAG=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g')" >> $GITHUB_ENV
- name: Set up Docker Buildx
if: ${{ github.event_name == 'workflow_dispatch' || steps.changes.outputs.changed == 'true' || steps.changes.outputs.shared_utils_changed == 'true' || steps.changes.outputs.dockerfile_changed == 'true' || steps.changes.outputs.compose_changed == 'true' }}
uses: docker/setup-buildx-action@v4
with:
driver-opts: |
network=host
image=moby/buildkit:latest
buildkitd-flags: --debug
- name: Login to ghcr
if: ${{ github.event_name == 'workflow_dispatch' || steps.changes.outputs.changed == 'true' || steps.changes.outputs.shared_utils_changed == 'true' || steps.changes.outputs.dockerfile_changed == 'true' || steps.changes.outputs.compose_changed == 'true' }}
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHA_PAT }}
- name: Build and push
if: ${{ github.event_name == 'workflow_dispatch' || steps.changes.outputs.changed == 'true' || steps.changes.outputs.shared_utils_changed == 'true' || steps.changes.outputs.dockerfile_changed == 'true' || steps.changes.outputs.compose_changed == 'true' }}
uses: docker/bake-action@v7
with:
push: true
provenance: false
targets: ${{ matrix.service }}
set: |
*.platform=linux/arm64,linux/amd64/v3
${{ matrix.service }}.tags=ghcr.io/${{ github.repository_owner }}/${{ matrix.service }}:${{ env.DOCKER_TAG }}
*.cache-from=
*.cache-to=