Skip to content

Commit 07836f3

Browse files
committed
Update CI/CD to build the image with the appropriate tag
1 parent 41d6948 commit 07836f3

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

.gitea/workflows/build_docker.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: Create Docker Image
22
run-name: ${{ gitea.actor }} Building Docker Image 🐳
33
on: [push]
44
env:
5-
VERSION: latest
65
DOCKER_HOST: tcp://127.0.0.1:2375
6+
ASSETS: 41d6948
77

88
jobs:
99
test:
@@ -66,7 +66,7 @@ jobs:
6666
public/js/manifest.js
6767
public/js/vendor.js
6868
#key: build-pla-page-assets-${{ hashFiles('**/package-lock.json') }}
69-
key: build-pla-page-assets-29f7ce2
69+
key: build-pla-page-assets-${{ env.ASSETS }}
7070
#restore-keys: |
7171
# build-pla-page-assets-
7272

@@ -85,7 +85,6 @@ jobs:
8585
privileged: true
8686
env:
8787
ARCH: ${{ matrix.arch }}
88-
VERSIONARCH: ${{ env.VERSION }}-${{ env.ARCH }}
8988

9089
steps:
9190
- name: Environment Setup
@@ -130,7 +129,7 @@ jobs:
130129
public/js/manifest.js
131130
public/js/vendor.js
132131
#key: build-pla-page-assets-${{ hashFiles('**/package-lock.json') }}
133-
key: build-pla-page-assets-29f7ce2
132+
key: build-pla-page-assets-${{ env.ASSETS }}
134133
#restore-keys: |
135134
# build-pla-page-assets-
136135

@@ -145,23 +144,23 @@ jobs:
145144
- name: Record version and Delete Unnecessary files
146145
id: prebuild
147146
run: |
148-
echo "version=$(cat public/VERSION)" >> "$GITHUB_OUTPUT"
149-
echo "revision=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
150147
echo ${GITHUB_SHA::8} > VERSION
148+
# [ "${GITHUB_REF_TYPE}" -eq "tag" ] && echo v${GITHUB_REF_NAME}-rel > public/VERSION
151149
rm -rf .git* tests/ storage/app/test/
152-
ls -al public/css/
153-
ls -al public/js/
150+
cat VERSION public/VERSION
151+
# ls -al public/css/
152+
# ls -al public/js/
154153
155154
- name: Build and Push Docker Image
156155
uses: docker/build-push-action@v5
157156
with:
158157
context: .
159158
file: docker/Dockerfile
160159
push: true
161-
tags: "${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSIONARCH }}"
160+
tags: "${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.GITHUB_REF_NAME }}-${{ env.ARCH }}"
162161
build-args: |
163-
BUILD_REVISION=${{ steps.prebuild.outputs.revision }}
164-
BUILD_VERSION=${{ steps.prebuild.outputs.version }}
162+
BUILD_REVISION=${{ env.GITHUB_SHA }}
163+
BUILD_VERSION=v${{ env.GITHUB_REF_NAME }}
165164
166165
manifest:
167166
name: Final Docker Image Manifest
@@ -196,7 +195,8 @@ jobs:
196195

197196
- name: Build Docker Manifest
198197
run: |
199-
docker manifest create ${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }} \
200-
${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }}-x86_64 \
201-
${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }}-arm64
202-
docker manifest push --purge ${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.VERSION }}
198+
docker manifest create ${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.GITHUB_REF_NAME }} \
199+
${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.GITHUB_REF_NAME }}-x86_64 \
200+
${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.GITHUB_REF_NAME }}-arm64
201+
docker manifest push --purge ${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.GITHUB_REF_NAME }}
202+
echo "Built container: ${{ steps.registry.outputs.registry }}/${{ env.GITHUB_REPOSITORY }}:${{ env.GITHUB_REF_NAME }}"

0 commit comments

Comments
 (0)