Skip to content

Commit 7729bbf

Browse files
committed
Updated workflows.
1 parent 3eb2e89 commit 7729bbf

File tree

3 files changed

+53
-71
lines changed

3 files changed

+53
-71
lines changed

.github/workflows/cd-manual.yml

Lines changed: 0 additions & 58 deletions
This file was deleted.

.github/workflows/cd.yml

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
name: Create docker images
22

3-
on: [create]
3+
on:
4+
create:
5+
workflow_dispatch:
6+
inputs:
7+
tag:
8+
description: 'Tag to build (e.g., v2.10.0, 2.10.0, v2.10, v2)'
9+
required: true
10+
type: string
411

512
jobs:
613
build:
714
name: Build, push, and deploy
8-
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
15+
if: ${{ startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' }}
916
runs-on: ubuntu-latest
1017

1118
strategy:
@@ -14,6 +21,8 @@ jobs:
1421

1522
steps:
1623
- uses: actions/checkout@v3
24+
with:
25+
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
1726

1827
- name: Set env
1928
run: |
@@ -22,15 +31,41 @@ jobs:
2231
- name: Generate tags
2332
id: generate_tags
2433
run: |
25-
echo "tag_patch=$(echo ${{ matrix.db-type }})-${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
26-
echo "tag_minor=$(echo ${{ matrix.db-type }})-$(echo ${GITHUB_REF#refs/tags/} | cut -d. -f1,2)" >> $GITHUB_ENV
27-
echo "tag_major=$(echo ${{ matrix.db-type }})-$(echo ${GITHUB_REF#refs/tags/} | cut -d. -f1)" >> $GITHUB_ENV
34+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
35+
TAG=${{ inputs.tag }}
36+
else
37+
TAG=${GITHUB_REF#refs/tags/}
38+
fi
39+
40+
# Remove 'v' prefix if present
41+
VERSION=${TAG#v}
42+
43+
# Split version into parts
44+
IFS='.' read -ra PARTS <<< "$VERSION"
45+
46+
# Generate tags based on number of version parts
47+
if [ ${#PARTS[@]} -eq 1 ]; then
48+
# Only major version (e.g., v2 or 2)
49+
echo "tag_major=$(echo ${{ matrix.db-type }})-${PARTS[0]}" >> $GITHUB_ENV
50+
echo "TAGS=${{ matrix.db-type }}-${PARTS[0]}" >> $GITHUB_ENV
51+
elif [ ${#PARTS[@]} -eq 2 ]; then
52+
# Major.minor version (e.g., v2.10 or 2.10)
53+
echo "tag_major=$(echo ${{ matrix.db-type }})-${PARTS[0]}" >> $GITHUB_ENV
54+
echo "tag_minor=$(echo ${{ matrix.db-type }})-${PARTS[0]}.${PARTS[1]}" >> $GITHUB_ENV
55+
echo "TAGS=${{ matrix.db-type }}-${PARTS[0]}, ${{ matrix.db-type }}-${PARTS[0]}.${PARTS[1]}" >> $GITHUB_ENV
56+
else
57+
# Full version (e.g., v2.10.0 or 2.10.0)
58+
echo "tag_major=$(echo ${{ matrix.db-type }})-${PARTS[0]}" >> $GITHUB_ENV
59+
echo "tag_minor=$(echo ${{ matrix.db-type }})-${PARTS[0]}.${PARTS[1]}" >> $GITHUB_ENV
60+
echo "tag_patch=$(echo ${{ matrix.db-type }})-${VERSION}" >> $GITHUB_ENV
61+
echo "TAGS=${{ matrix.db-type }}-${PARTS[0]}, ${{ matrix.db-type }}-${PARTS[0]}.${PARTS[1]}, ${{ matrix.db-type }}-${VERSION}" >> $GITHUB_ENV
62+
fi
2863
2964
- uses: mr-smithers-excellent/docker-build-push@v6
3065
name: Build & push Docker image to ghcr.io for ${{ matrix.db-type }}
3166
with:
3267
image: umami
33-
tags: ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}
68+
tags: ${{ env.TAGS }}
3469
buildArgs: DATABASE_TYPE=${{ matrix.db-type }}
3570
registry: ghcr.io
3671
multiPlatform: true
@@ -42,8 +77,8 @@ jobs:
4277
name: Build & push Docker image to docker.io for ${{ matrix.db-type }}
4378
with:
4479
image: umamisoftware/umami
45-
tags: ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}
80+
tags: ${{ env.TAGS }}
4681
buildArgs: DATABASE_TYPE=${{ matrix.db-type }}
4782
registry: docker.io
4883
username: ${{ secrets.DOCKER_USERNAME }}
49-
password: ${{ secrets.DOCKER_PASSWORD }}
84+
password: ${{ secrets.DOCKER_PASSWORD }}

.github/workflows/ci.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,19 @@ jobs:
2525

2626
steps:
2727
- uses: actions/checkout@v4
28+
29+
- uses: pnpm/action-setup@v2
30+
with:
31+
version: 8
32+
2833
- name: Use Node.js ${{ matrix.node-version }}
2934
uses: actions/setup-node@v4
3035
with:
3136
node-version: ${{ matrix.node-version }}
32-
cache: 'yarn'
37+
cache: 'pnpm'
3338
env:
3439
DATABASE_TYPE: ${{ matrix.db-type }}
35-
- run: npm install --global yarn
36-
- run: yarn install
37-
- run: yarn test
38-
- run: yarn build
40+
41+
- run: pnpm install
42+
- run: pnpm test
43+
- run: pnpm build

0 commit comments

Comments
 (0)