Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.

Commit 366b26a

Browse files
committed
Add CI/CD workflow to build and push to ECR
- Builds patched Quickwit datasource plugin - Removes signature files for patched version - Builds Grafana Docker image with patched plugin - Pushes to ECR repository: grafana-quickwit - Triggers on push to disable-field-caps-all-fields branch or tags
1 parent 2a5494c commit 366b26a

1 file changed

Lines changed: 178 additions & 0 deletions

File tree

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: Build and Push Grafana with Quickwit Plugin
2+
3+
on:
4+
push:
5+
branches:
6+
- disable-field-caps-all-fields
7+
- main
8+
tags:
9+
- 'v*'
10+
workflow_dispatch:
11+
12+
env:
13+
GRAFANA_VERSION: 12.4.0
14+
AWS_REGION: us-east-1
15+
ECR_REPOSITORY: grafana-quickwit
16+
17+
jobs:
18+
build-plugin:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '20'
29+
cache: 'npm'
30+
31+
- name: Setup Go
32+
uses: actions/setup-go@v5
33+
with:
34+
go-version: '1.21'
35+
36+
- name: Install dependencies
37+
run: npm ci
38+
39+
- name: Build frontend
40+
run: npm run build
41+
42+
- name: Build backend binaries
43+
run: |
44+
mage -v buildAll || echo "Mage not available, using go build"
45+
if [ ! -f dist/gpx_quickwit_linux_amd64 ]; then
46+
cd pkg
47+
GOOS=linux GOARCH=amd64 go build -o ../dist/gpx_quickwit_linux_amd64 .
48+
GOOS=linux GOARCH=arm64 go build -o ../dist/gpx_quickwit_linux_arm64 .
49+
fi
50+
51+
- name: Remove signature files for patched plugin
52+
run: |
53+
cd dist
54+
rm -f MANIFEST.txt
55+
jq 'del(.signature)' plugin.json > plugin.json.tmp && mv plugin.json.tmp plugin.json
56+
57+
- name: Package plugin
58+
run: |
59+
cd dist
60+
zip -r quickwit-quickwit-datasource-patched.zip . -x "*.zip"
61+
62+
- name: Upload plugin artifact
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: quickwit-plugin-patched
66+
path: dist/quickwit-quickwit-datasource-patched.zip
67+
retention-days: 30
68+
69+
build-and-push-image:
70+
needs: build-plugin
71+
runs-on: ubuntu-latest
72+
permissions:
73+
id-token: write
74+
contents: read
75+
76+
steps:
77+
- name: Checkout code
78+
uses: actions/checkout@v4
79+
80+
- name: Download plugin artifact
81+
uses: actions/download-artifact@v4
82+
with:
83+
name: quickwit-plugin-patched
84+
path: ./plugin
85+
86+
- name: Configure AWS credentials
87+
uses: aws-actions/configure-aws-credentials@v4
88+
with:
89+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
90+
aws-region: ${{ env.AWS_REGION }}
91+
92+
- name: Login to Amazon ECR
93+
id: login-ecr
94+
uses: aws-actions/amazon-ecr-login@v2
95+
96+
- name: Generate image tags
97+
id: meta
98+
run: |
99+
BRANCH_NAME=${GITHUB_REF#refs/heads/}
100+
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
101+
102+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
103+
TAG_VERSION=${GITHUB_REF#refs/tags/v}
104+
IMAGE_TAG="${GRAFANA_VERSION}-quickwit-${TAG_VERSION}"
105+
else
106+
IMAGE_TAG="${GRAFANA_VERSION}-quickwit-0.6.0-patched-${SHORT_SHA}"
107+
fi
108+
109+
echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
110+
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
111+
112+
if [[ "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == refs/tags/* ]]; then
113+
TAGS="${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${IMAGE_TAG}"
114+
TAGS="${TAGS},${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:latest"
115+
else
116+
TAGS="${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${IMAGE_TAG}"
117+
fi
118+
119+
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
120+
121+
- name: Create Dockerfile
122+
run: |
123+
cat > Dockerfile <<'EOF'
124+
FROM grafana/grafana:${{ env.GRAFANA_VERSION }}
125+
126+
USER root
127+
128+
# Install patched Quickwit plugin
129+
COPY plugin/quickwit-quickwit-datasource-patched.zip /tmp/plugin.zip
130+
RUN set -ex && \
131+
mkdir -p /var/lib/grafana/plugins && \
132+
cd /var/lib/grafana/plugins && \
133+
unzip -q /tmp/plugin.zip -d quickwit-quickwit-datasource && \
134+
rm /tmp/plugin.zip && \
135+
chown -R 472:0 /var/lib/grafana/plugins
136+
137+
USER grafana
138+
139+
ENV GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=quickwit-quickwit-datasource
140+
141+
LABEL org.opencontainers.image.source="https://github.com/Iterable/quickwit-datasource"
142+
LABEL org.opencontainers.image.description="Grafana with patched Quickwit datasource plugin (field_caps disabled)"
143+
LABEL grafana.version="${{ env.GRAFANA_VERSION }}"
144+
LABEL quickwit.plugin.version="0.6.0-patched"
145+
146+
EXPOSE 3000
147+
148+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
149+
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
150+
EOF
151+
152+
- name: Set up Docker Buildx
153+
uses: docker/setup-buildx-action@v3
154+
155+
- name: Build and push Docker image
156+
uses: docker/build-push-action@v5
157+
with:
158+
context: .
159+
file: ./Dockerfile
160+
push: true
161+
tags: ${{ steps.meta.outputs.tags }}
162+
cache-from: type=gha
163+
cache-to: type=gha,mode=max
164+
provenance: false
165+
166+
- name: Output image details
167+
run: |
168+
echo "### Docker Image Pushed 🚀" >> $GITHUB_STEP_SUMMARY
169+
echo "" >> $GITHUB_STEP_SUMMARY
170+
echo "**Registry**: ${{ steps.login-ecr.outputs.registry }}" >> $GITHUB_STEP_SUMMARY
171+
echo "**Repository**: ${{ env.ECR_REPOSITORY }}" >> $GITHUB_STEP_SUMMARY
172+
echo "**Tags**:" >> $GITHUB_STEP_SUMMARY
173+
echo '```' >> $GITHUB_STEP_SUMMARY
174+
echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n' >> $GITHUB_STEP_SUMMARY
175+
echo '```' >> $GITHUB_STEP_SUMMARY
176+
echo "" >> $GITHUB_STEP_SUMMARY
177+
echo "**Grafana Version**: ${{ env.GRAFANA_VERSION }}" >> $GITHUB_STEP_SUMMARY
178+
echo "**Quickwit Plugin**: 0.6.0-patched (field_caps disabled)" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)