Skip to content

Commit 6bddd7f

Browse files
♻️ Use composite action for version info extraction
Instead of the copy-pasted shell script.
1 parent d3f9a74 commit 6bddd7f

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,26 +126,15 @@ jobs:
126126
- uses: actions/checkout@v4
127127
- name: Determine tag/commit hash
128128
id: vars
129-
run: |
130-
# Strip git ref prefix from version
131-
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
132-
133-
# Strip "v" prefix from tag name (if present at all)
134-
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
135-
136-
# Use Docker `latest` tag convention
137-
[ "$VERSION" == "${{ inputs.main-branch }}" ] && VERSION=latest
138-
139-
echo "tag=${VERSION}" >> $GITHUB_OUTPUT
140-
echo "git_hash=${GITHUB_SHA}" >> $GITHUB_OUTPUT
129+
uses: maykinmedia/open-api-workflows/actions/extract-version@feature/extract-and-polish-reusable-actions
141130
- name: Build the Docker image
142131
run: |
143132
docker build \
144-
--tag ${{ inputs.docker-image-name }}:${{ steps.vars.outputs.tag }} \
133+
--tag ${{ inputs.docker-image-name }}:${{ steps.vars.outputs.version }} \
145134
--build-arg COMMIT_HASH=${{ steps.vars.outputs.git_hash }} \
146-
--build-arg RELEASE=${{ steps.vars.outputs.tag }} \
135+
--build-arg RELEASE=${{ steps.vars.outputs.version }} \
147136
.
148-
- run: docker image save -o image.tar ${{ inputs.docker-image-name }}:${{ steps.vars.outputs.tag }}
137+
- run: docker image save -o image.tar ${{ inputs.docker-image-name }}:${{ steps.vars.outputs.version }}
149138
- name: Store image artifact
150139
uses: actions/upload-artifact@v4
151140
with:

.github/workflows/publish.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,7 @@ jobs:
3939

4040
- name: Determine tag/commit hash
4141
id: vars
42-
run: |
43-
# Strip git ref prefix from version
44-
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
45-
46-
# Use Docker `latest` tag convention for the default branch
47-
[[ "${{ github.event.repository.default_branch }}" == $VERSION ]] && VERSION=latest
48-
49-
# Strip "v" prefix from tag name (if present at all)
50-
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
51-
52-
echo "tag=${VERSION}" >> $GITHUB_OUTPUT
42+
uses: maykinmedia/open-api-workflows/actions/extract-version@feature/extract-and-polish-reusable-actions
5343

5444
- name: Load image
5545
run: |
@@ -59,13 +49,13 @@ jobs:
5949
run: echo "${{ secrets.docker-token }}" | docker login -u ${{ secrets.docker-username }} --password-stdin
6050

6151
- name: Push the Docker image
62-
run: docker push ${{ inputs.docker-image-name }}:${{ steps.vars.outputs.tag }}
52+
run: docker push ${{ inputs.docker-image-name }}:${{ steps.vars.outputs.version }}
6353

6454
- name: Push stable tag
6555
if: >
6656
startsWith(github.ref, 'refs/tags/') &&
6757
matches(github.ref, '^refs/tags/v?[0-9]+\\.[0-9]+(\\.[0-9]+)?$')
6858
run: |
69-
docker tag ${{ inputs.docker-image-name }}:${{ steps.vars.outputs.tag }} \
59+
docker tag ${{ inputs.docker-image-name }}:${{ steps.vars.outputs.version }} \
7060
${{ inputs.docker-image-name }}:stable
7161
docker push ${{ inputs.docker-image-name }}:stable

0 commit comments

Comments
 (0)