Skip to content

Commit 0a4613f

Browse files
authored
Merge pull request #1 from KBVE/feature/docker-build-workflow
feat: add manual Docker build and release workflow
2 parents d9e1fe0 + 51cf86b commit 0a4613f

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Manual Docker Build & Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
docker_tag:
7+
description: 'Docker tag for the image'
8+
required: true
9+
default: 'latest'
10+
type: string
11+
git_ref:
12+
description: 'Git ref to build (branch/tag/commit)'
13+
required: false
14+
default: 'main'
15+
type: string
16+
17+
jobs:
18+
build-and-push:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
with:
28+
ref: ${{ inputs.git_ref }}
29+
30+
- name: Extract version from mix.exs
31+
id: version
32+
run: |
33+
VERSION=$(grep -oP 'version: "\K[^"]+' mix.exs)
34+
echo "version=$VERSION" >> $GITHUB_OUTPUT
35+
echo "Extracted version: $VERSION"
36+
37+
- name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v3
39+
40+
- name: Login to GitHub Container Registry
41+
uses: docker/login-action@v3
42+
with:
43+
registry: ghcr.io
44+
username: ${{ github.actor }}
45+
password: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Extract metadata
48+
id: meta
49+
uses: docker/metadata-action@v5
50+
with:
51+
images: ghcr.io/kbve/realtime
52+
tags: |
53+
type=raw,value=${{ inputs.docker_tag }}
54+
type=raw,value=v${{ steps.version.outputs.version }}
55+
type=sha,prefix={{branch}}-
56+
type=raw,value={{branch}}-{{date 'YYYYMMDD-HHmmss'}}
57+
labels: |
58+
org.opencontainers.image.title=Supabase Realtime
59+
org.opencontainers.image.description=Realtime server for Supabase
60+
org.opencontainers.image.vendor=Supabase
61+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
62+
63+
- name: Build and push Docker image
64+
uses: docker/build-push-action@v5
65+
with:
66+
context: .
67+
platforms: linux/amd64
68+
push: true
69+
tags: ${{ steps.meta.outputs.tags }}
70+
labels: ${{ steps.meta.outputs.labels }}
71+
cache-from: type=gha
72+
cache-to: type=gha,mode=max
73+
74+
- name: Output image details
75+
run: |
76+
echo "## Docker Image Built Successfully! 🚀" >> $GITHUB_STEP_SUMMARY
77+
echo "" >> $GITHUB_STEP_SUMMARY
78+
echo "**Image Registry:** GitHub Container Registry" >> $GITHUB_STEP_SUMMARY
79+
echo "**Primary Tag:** \`ghcr.io/kbve/realtime:${{ inputs.docker_tag }}\`" >> $GITHUB_STEP_SUMMARY
80+
echo "**Version Tag:** \`ghcr.io/kbve/realtime:v${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
81+
echo "" >> $GITHUB_STEP_SUMMARY
82+
echo "### All Tags:" >> $GITHUB_STEP_SUMMARY
83+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
84+
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
85+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
86+
echo "" >> $GITHUB_STEP_SUMMARY
87+
echo "### Pull Command:" >> $GITHUB_STEP_SUMMARY
88+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
89+
echo "docker pull ghcr.io/kbve/realtime:${{ inputs.docker_tag }}" >> $GITHUB_STEP_SUMMARY
90+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
91+
echo "" >> $GITHUB_STEP_SUMMARY
92+
echo "### Run Command:" >> $GITHUB_STEP_SUMMARY
93+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
94+
echo "docker run -p 4000:4000 ghcr.io/kbve/realtime:${{ inputs.docker_tag }}" >> $GITHUB_STEP_SUMMARY
95+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)