-
Notifications
You must be signed in to change notification settings - Fork 113
168 lines (146 loc) · 4.87 KB
/
build-gateway.yml
File metadata and controls
168 lines (146 loc) · 4.87 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
name: Build Gateway
on:
push:
tags:
- "gateway-v*"
workflow_dispatch:
inputs:
tag:
description: 'Version tag (e.g. gateway-v0.1.0)'
required: true
type: string
dry_run:
description: 'Dry run (build only, no push)'
required: false
type: boolean
default: false
env:
IMAGE_NAME: ghcr.io/openabdev/openab-gateway
jobs:
build:
strategy:
matrix:
platform:
- { os: linux/amd64, runner: ubuntu-latest }
- { os: linux/arm64, runner: ubuntu-24.04-arm }
runs-on: ${{ matrix.platform.runner }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- name: Resolve tag
id: tag
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ inputs.tag }}"
else
TAG="${GITHUB_REF_NAME}"
fi
VERSION="${TAG#gateway-v}"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
file: gateway/Dockerfile
platforms: ${{ matrix.platform.os }}
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ inputs.dry_run != true }}
cache-from: type=gha,scope=gateway-${{ matrix.platform.os }}
cache-to: type=gha,scope=gateway-${{ matrix.platform.os }},mode=max
- name: Export digest
if: inputs.dry_run != true
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
if: inputs.dry_run != true
uses: actions/upload-artifact@v4
with:
name: gateway-digest-${{ matrix.platform.runner }}
path: /tmp/digests/*
retention-days: 1
merge:
needs: build
if: ${{ !cancelled() && (github.event_name == 'push' || inputs.dry_run != true) }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Resolve tag
id: tag
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ inputs.tag }}"
else
TAG="${GITHUB_REF_NAME}"
fi
echo "version=${TAG#gateway-v}" >> "$GITHUB_OUTPUT"
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download digests
uses: actions/download-artifact@v4
with:
pattern: gateway-digest-*
path: /tmp/digests
merge-multiple: true
- name: Create multi-arch manifest
run: |
cd /tmp/digests
docker buildx imagetools create \
-t ${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.version }} \
-t ${{ env.IMAGE_NAME }}:latest \
$(printf '${{ env.IMAGE_NAME }}@sha256:%s ' *)
release:
needs: [build, merge]
if: ${{ !cancelled() && needs.merge.result == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Resolve version
id: tag
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ inputs.tag }}"
else
TAG="${GITHUB_REF_NAME}"
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "version=${TAG#gateway-v}" >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ steps.tag.outputs.tag }}"
VERSION="${{ steps.tag.outputs.version }}"
cat > /tmp/release-notes.md << EOF
## OpenAB Custom Gateway v${VERSION}
Standalone gateway service — bridges webhook-based platforms to OAB via WebSocket.
### Docker
\`\`\`bash
docker pull ghcr.io/openabdev/openab-gateway:${VERSION}
\`\`\`
Multi-arch: linux/amd64 + linux/arm64
### Links
- [Gateway README](https://github.com/openabdev/openab/blob/main/gateway/README.md)
- [ADR: Custom Gateway](https://github.com/openabdev/openab/blob/main/docs/adr/custom-gateway.md)
EOF
sed -i 's/^ //' /tmp/release-notes.md
gh release create "$TAG" \
--title "Gateway v${VERSION}" \
--notes-file /tmp/release-notes.md