Skip to content

Commit 70b832f

Browse files
committed
Fix tag ci
1 parent 65c1c10 commit 70b832f

File tree

4 files changed

+73
-18
lines changed

4 files changed

+73
-18
lines changed

.github/actions/build-app/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
platforms:
1414
required: true
1515
description: Image platforms
16+
latest:
17+
required: false
18+
description: Tag image as latest
19+
default: false
1620

1721
runs:
1822
using: composite
@@ -27,8 +31,12 @@ runs:
2731
latest=false
2832
tags: |
2933
type=raw,value={{branch}},enable=${{ github.ref_type == 'branch' && github.event_name != 'pull_request' }}
34+
type=raw,value=latest,enable=${{ inputs.latest }}
3035
type=ref,event=branch
3136
type=ref,event=pr
37+
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
38+
type=semver,pattern={{major}}.{{minor}}
39+
type=semver,pattern={{major}}.{{minor}}.{{patch}}
3240
3341
- name: Build and push
3442
uses: docker/build-push-action@v6
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: build-app
2+
description: Build and Push Docker Image
3+
inputs:
4+
dockerfile:
5+
required: true
6+
description: Dockerfile path
7+
push:
8+
required: true
9+
description: Push image to registry
10+
image:
11+
required: true
12+
description: Image name
13+
platforms:
14+
required: true
15+
description: Image platforms
16+
17+
runs:
18+
using: composite
19+
20+
steps:
21+
- name: Extract metadata (tags, labels) for Docker
22+
id: meta
23+
uses: docker/metadata-action@v5
24+
with:
25+
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ inputs.image }}
26+
flavor: |
27+
latest=false
28+
tags: |
29+
type=raw,value={{branch}},enable=${{ github.ref_type == 'branch' && github.event_name != 'pull_request' }}
30+
type=ref,event=branch
31+
type=ref,event=pr
32+
33+
- name: Build and push
34+
uses: docker/build-push-action@v6
35+
with:
36+
context: .
37+
file: ${{ inputs.dockerfile }}
38+
push: ${{ inputs.push }}
39+
tags: ${{ steps.meta.outputs.tags }}
40+
labels: ${{ steps.meta.outputs.labels }}
41+
platforms: ${{ inputs.platforms }}

.github/workflows/ci-build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ on:
1414
description: 'Platforms to build for'
1515
required: false
1616
type: string
17+
latest:
18+
description: 'Tag image as latest'
19+
required: false
20+
type: boolean
21+
default: false
1722
workflow_dispatch:
1823

1924
name: ci-build
@@ -47,6 +52,7 @@ jobs:
4752
push: ${{ github.event_name != 'pull_request' }}
4853
image: api
4954
platforms: ${{ inputs.platforms || 'linux/amd64' }}
55+
latest: ${{ inputs.latest || false }}
5056

5157
- name: Build LiveControlGateway
5258
uses: ./.github/actions/build-app
@@ -55,6 +61,7 @@ jobs:
5561
push: ${{ github.event_name != 'pull_request' }}
5662
image: live-control-gateway
5763
platforms: ${{ inputs.platforms || 'linux/amd64' }}
64+
latest: ${{ inputs.latest || false }}
5865

5966
- name: Build Cron
6067
uses: ./.github/actions/build-app
@@ -63,6 +70,7 @@ jobs:
6370
push: ${{ github.event_name != 'pull_request' }}
6471
image: cron
6572
platforms: ${{ inputs.platforms || 'linux/amd64' }}
73+
latest: ${{ inputs.latest || false }}
6674

6775
deploy-production:
6876
runs-on: ubuntu-latest

.github/workflows/ci-tag.yml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,24 @@ env:
1313

1414
jobs:
1515

16+
# Pre-job to find the latest tag
17+
get-latest-tag:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
latest-tag: ${{ steps.latest-tag.outputs.tag }}
21+
steps:
22+
- name: Find latest tag
23+
id: latest-tag
24+
uses: oprypin/find-latest-tag@v1
25+
with:
26+
repository: ${{ github.repository }}
27+
regex: '^[0-9]+\\.[0-9]+\\.[0-9]+$'
28+
releases-only: false
29+
1630
# Delegate building and containerizing to a single workflow.
1731
build-and-containerize:
32+
needs: get-latest-tag
1833
uses: ./.github/workflows/ci-build.yml
1934
with:
2035
platforms: linux/amd64,linux/arm64
21-
22-
release:
23-
runs-on: ubuntu-latest
24-
needs: build-and-containerize
25-
26-
steps:
27-
- name: Download release notes
28-
uses: actions/checkout@v4
29-
with:
30-
sparse-checkout: |
31-
README.md
32-
33-
- name: Create release
34-
uses: softprops/action-gh-release@v2
35-
with:
36-
body_path: README.md
37-
tag_name: ${{ github.ref_name }}
38-
prerelease: ${{ contains(github.ref_name, '-rc') }}
36+
latest: ${{ needs.get-latest-tag.outputs.latest-tag == github.ref_name }}

0 commit comments

Comments
 (0)