ci: build images from a dev branch and release tags, not every commit
Every push to master was triggering a build+push, since that's where day-to-day commits land. Switch to two deliberate channels instead: pushing to dev produces a rolling :dev tag for testing, and pushing a v* tag produces :latest + the version tag for real releases. Plain commits/merges to master/main no longer build anything on their own.
This commit is contained in:
@@ -1,8 +1,12 @@
|
|||||||
name: Publish Docker image
|
name: Publish Docker image
|
||||||
|
|
||||||
|
# Two channels, not one-image-per-commit:
|
||||||
|
# - push to `dev` -> rolling `:dev` tag, for testing in-progress work
|
||||||
|
# - push tag `v*` -> `:latest` + the version tag, for actual releases
|
||||||
|
# Plain commits/merges to master/main build nothing on their own.
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, master]
|
branches: [dev]
|
||||||
tags: ['v*']
|
tags: ['v*']
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
@@ -20,6 +24,24 @@ jobs:
|
|||||||
- name: Compute lowercase image name
|
- name: Compute lowercase image name
|
||||||
run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
|
run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Compute image tags
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.ref_type }}" = "tag" ]; then
|
||||||
|
VERSION="${{ github.ref_name }}"
|
||||||
|
TAGS="${{ vars.REGISTRY_HOST }}/${IMAGE_NAME}:latest
|
||||||
|
${{ vars.REGISTRY_HOST }}/${IMAGE_NAME}:${VERSION}
|
||||||
|
ghcr.io/${IMAGE_NAME}:latest
|
||||||
|
ghcr.io/${IMAGE_NAME}:${VERSION}"
|
||||||
|
else
|
||||||
|
TAGS="${{ vars.REGISTRY_HOST }}/${IMAGE_NAME}:dev
|
||||||
|
ghcr.io/${IMAGE_NAME}:dev"
|
||||||
|
fi
|
||||||
|
{
|
||||||
|
echo "TAGS<<TAGS_EOF"
|
||||||
|
echo "$TAGS"
|
||||||
|
echo "TAGS_EOF"
|
||||||
|
} >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Log in to Gitea container registry
|
- name: Log in to Gitea container registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
@@ -39,8 +61,4 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: ${{ env.TAGS }}
|
||||||
${{ vars.REGISTRY_HOST }}/${{ env.IMAGE_NAME }}:latest
|
|
||||||
${{ vars.REGISTRY_HOST }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
|
||||||
ghcr.io/${{ env.IMAGE_NAME }}:latest
|
|
||||||
ghcr.io/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
|
||||||
|
|||||||
@@ -51,6 +51,19 @@ Types: `feat`, `fix`, `refactor`, `style`, `docs`, `chore`, `test`.
|
|||||||
Tag production releases as `v<major>.<minor>.<patch>` (semver) once this
|
Tag production releases as `v<major>.<minor>.<patch>` (semver) once this
|
||||||
project has a deployment cadence worth marking. Not required for every merge.
|
project has a deployment cadence worth marking. Not required for every merge.
|
||||||
|
|
||||||
|
## Docker images
|
||||||
|
|
||||||
|
CI (`.gitea/workflows/docker-publish.yml`) only builds an image on two
|
||||||
|
events, not on every commit:
|
||||||
|
|
||||||
|
- push to `dev` — builds a rolling `:dev` tag, for testing in-progress work
|
||||||
|
before it's ready to release.
|
||||||
|
- push a `v*` tag — builds `:latest` plus the version tag, for actual
|
||||||
|
releases.
|
||||||
|
|
||||||
|
Push to `dev` when you want a throwaway build to test; tag a release on
|
||||||
|
`main`/`master` when you want a real one.
|
||||||
|
|
||||||
## What not to commit
|
## What not to commit
|
||||||
|
|
||||||
- Anything in `.gitignore` (`.env`, `/data`, `.next`, `node_modules`, prisma
|
- Anything in `.gitignore` (`.env`, `/data`, `.next`, `node_modules`, prisma
|
||||||
|
|||||||
Reference in New Issue
Block a user