build: add major version tag for docker images

This commit is contained in:
dumbmoron 2023-12-02 16:59:37 +00:00
parent 83d82f5da9
commit 08edf28ccf
No known key found for this signature in database
GPG key ID: C59997C76C6A8E5F
2 changed files with 13 additions and 11 deletions

View file

@ -29,20 +29,22 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get version from package.json
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1
- name: Get short commit hash
id: commit-hash
run: echo "commit_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Get release metadata
id: release-meta
run: |
version=$(cat package.json | jq -r .version)
echo "commit_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT
echo "major_version=$(echo "$version" | cut -d. -f1)" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
tags: |
type=raw,value=latest
type=raw,value=${{ steps.package-version.outputs.current-version }}
type=raw,value=${{ steps.package-version.outputs.current-version }}-${{ steps.commit-hash.outputs.commit_short }}
type=raw,value=${{ steps.release-meta.outputs.version }}
type=raw,value=${{ steps.release-meta.outputs.major_version }}
type=raw,value=${{ steps.release-meta.outputs.version }}-${{ steps.release-meta.outputs.commit_short }}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image

View file

@ -2,7 +2,7 @@ version: '3.5'
services:
cobalt-api:
image: ghcr.io/wukko/cobalt:latest
image: ghcr.io/wukko/cobalt:7
restart: unless-stopped
container_name: cobalt-api
@ -32,7 +32,7 @@ services:
#- ./cookies.json:/cookies.json
cobalt-web:
image: ghcr.io/wukko/cobalt:latest
image: ghcr.io/wukko/cobalt:7
restart: unless-stopped
container_name: cobalt-web
@ -61,4 +61,4 @@ services:
restart: unless-stopped
command: --cleanup --scope cobalt --interval 900
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/run/docker.sock:/var/run/docker.sock