Skip to content

Commit 9c1d759

Browse files
committed
use git tag
1 parent 1f201fa commit 9c1d759

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

.github/workflows/ghcr.yaml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
name: ghcr
22
on:
3-
workflow_dispatch:
4-
inputs:
5-
version:
6-
type: string
7-
required: true
8-
description: version (e.g. 1.2.3)
3+
push:
4+
tags:
5+
- "v*"
96
env:
107
IMAGE_NAME: workshop-azure-openai
118
jobs:
12-
publish:
9+
ghcr:
1310
runs-on: ubuntu-latest
11+
timeout-minutes: 5
1412
permissions:
1513
packages: write
1614
contents: read
@@ -21,12 +19,25 @@ jobs:
2119
registry: ghcr.io
2220
username: ${{ github.actor }}
2321
password: ${{ secrets.GITHUB_TOKEN }}
24-
- uses: docker/metadata-action@v5
22+
- name: Set Versions
23+
uses: actions/github-script@v7
24+
id: set_version
25+
with:
26+
script: |
27+
const tag = context.ref.substring(10)
28+
const no_v = tag.replace('v', '')
29+
const dash_index = no_v.lastIndexOf('-')
30+
const no_dash = (dash_index > -1) ? no_v.substring(0, dash_index) : no_v
31+
core.setOutput('tag', tag)
32+
core.setOutput('no-v', no_v)
33+
core.setOutput('no-dash', no_dash)
34+
- name: Set meta data tag = ${{steps.set_version.outputs.no-dash}}
35+
uses: docker/metadata-action@v5
2536
id: meta
2637
with:
2738
images: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
2839
tags: |
29-
type=semver,pattern={{version}},value=v${{ inputs.version }}
40+
type=semver,pattern={{version}},value=v${{steps.set_version.outputs.no-dash}}
3041
type=raw,value=latest
3142
- uses: docker/build-push-action@v5
3243
with:

0 commit comments

Comments
 (0)