Skip to content

Commit 2438e1c

Browse files
CharmCharm
authored andcommitted
update ci
1 parent f39aa1c commit 2438e1c

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

.github/workflows/build-and-push.yml

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ jobs:
6363
context: ${{ matrix.service.context }}
6464
file: ${{ matrix.service.dockerfile }}
6565
push: true
66-
tags: ${{ env.REGISTRY }}/${{ env.DOCKERHUB_USERNAME }}/${{ matrix.service.image }}:${{ steps.extract_tag.outputs.tag_name }}
66+
tags: |
67+
${{ env.REGISTRY }}/${{ env.DOCKERHUB_USERNAME }}/${{ matrix.service.image }}:${{ steps.extract_tag.outputs.tag_name }}
68+
${{ env.REGISTRY }}/${{ env.DOCKERHUB_USERNAME }}/${{ matrix.service.image }}:latest
6769
cache-from: type=gha
6870
cache-to: type=gha,mode=max
6971
platforms: linux/amd64
@@ -103,6 +105,9 @@ jobs:
103105
echo "- \`${{ env.DOCKERHUB_USERNAME }}/lmeterx-be:$CURRENT_TAG\`" >> CHANGELOG.md
104106
echo "- \`${{ env.DOCKERHUB_USERNAME }}/lmeterx-eng:$CURRENT_TAG\`" >> CHANGELOG.md
105107
echo "- \`${{ env.DOCKERHUB_USERNAME }}/lmeterx-fe:$CURRENT_TAG\`" >> CHANGELOG.md
108+
echo "- \`${{ env.DOCKERHUB_USERNAME }}/lmeterx-be:latest\`" >> CHANGELOG.md
109+
echo "- \`${{ env.DOCKERHUB_USERNAME }}/lmeterx-eng:latest\`" >> CHANGELOG.md
110+
echo "- \`${{ env.DOCKERHUB_USERNAME }}/lmeterx-fe:latest\`" >> CHANGELOG.md
106111
echo "" >> CHANGELOG.md
107112
108113
if [ -n "$PREVIOUS_TAG" ]; then
@@ -125,25 +130,6 @@ jobs:
125130
env:
126131
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127132

128-
- name: Update docker-compose.yml
129-
run: |
130-
CURRENT_TAG=${{ steps.extract_tag.outputs.tag_name }}
131-
132-
# update docker-compose.yml with new image tags
133-
sed -i "s|${{ env.DOCKERHUB_USERNAME }}/lmeterx-be:.*|${{ env.DOCKERHUB_USERNAME }}/lmeterx-be:$CURRENT_TAG|g" docker-compose.yml
134-
sed -i "s|${{ env.DOCKERHUB_USERNAME }}/lmeterx-eng:.*|${{ env.DOCKERHUB_USERNAME }}/lmeterx-eng:$CURRENT_TAG|g" docker-compose.yml
135-
sed -i "s|${{ env.DOCKERHUB_USERNAME }}/lmeterx-fe:.*|${{ env.DOCKERHUB_USERNAME }}/lmeterx-fe:$CURRENT_TAG|g" docker-compose.yml
136-
137-
- name: Commit updated docker-compose.yml
138-
run: |
139-
git config --local user.email "action@github.com"
140-
git config --local user.name "GitHub Action"
141-
git add docker-compose.yml
142-
git diff --staged --quiet || git commit -m "Update docker-compose.yml to use ${{ steps.extract_tag.outputs.tag_name }} images"
143-
git push origin HEAD:main
144-
env:
145-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
146-
147133
notify:
148134
needs: [build-and-push, create-release]
149135
runs-on: ubuntu-latest
@@ -154,6 +140,7 @@ jobs:
154140
run: |
155141
if [ "${{ needs.build-and-push.result }}" == "success" ]; then
156142
echo "✅ Docker images built and pushed successfully!"
143+
echo "✅ Both versioned and latest tags have been updated!"
157144
else
158145
echo "❌ Docker image build failed!"
159146
exit 1

0 commit comments

Comments
 (0)