Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Build Docker images for each PR (#2152)

Vinicius Brasil7c24120ee193
diff --git a/.github/workflows/build-private-images.yml b/.github/workflows/build-private-images.yml
new file mode 100644
index 0000000000..700c582e22
--- /dev/null
+++ b/.github/workflows/build-private-images.yml
@@ -0,0 +1,47 @@
+name: Build Private Images
+
+on:
+ push:
+ branches: [master, stable]
+ pull_request:
+ branches: [master]
+ types: [synchronize, labeled]
+
+jobs:
+ build:
+ if: ${{ github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'deploy-to-staging') }}
+ runs-on: buildjet-4vcpu-ubuntu-2004
+
+ steps:
+ - name: Docker meta
+ id: meta
+ uses: docker/metadata-action@v4
+ with:
+ images: plausible/analytics-private
+ tags: |
+ type=ref,event=pr
+ type=ref,event=branch
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v1
+
+ - name: Login to DockerHub
+ uses: docker/login-action@v2
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Build and push
+ id: docker_build
+ uses: docker/build-push-action@v2
+ with:
+ push: true
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+ build-args: |
+ BUILD_METADATA=${{ steps.meta.outputs.json }}
+
+ - name: Image digest
+ run: echo ${{ steps.docker_build.outputs.digest }}
diff --git a/.github/workflows/docker.yml b/.github/workflows/build-public-images.yml
similarity index 85%
rename from .github/workflows/docker.yml
rename to .github/workflows/build-public-images.yml
index 3148504d6b..f64a460827 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/build-public-images.yml
@@ -1,8 +1,7 @@
-name: Build
+name: Build Public Images
on:
push:
- branches: [master, stable, dev]
tags: ['v*']
jobs:
@@ -16,7 +15,6 @@ jobs:
with:
images: plausible/analytics
tags: |
- type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
@@ -25,7 +23,6 @@ jobs:
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
- if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
@@ -35,7 +32,6 @@ jobs:
id: docker_build
uses: docker/build-push-action@v2
with:
- push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha