fix: refactor GitHub Actions workflow to separate test and build-and-push jobs, and streamline image tagging process

This commit is contained in:
2026-03-06 21:35:33 +07:00
parent ac4ccc498e
commit 430ad2efeb
2 changed files with 33 additions and 39 deletions

View File

@@ -6,29 +6,46 @@ on:
- v* - v*
jobs: jobs:
docker: test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install mise
run: curl https://mise.run | sh
- name: Setup environment
run: |
mise install
just setup
- name: Run tests
run: just test
build-and-push:
needs: test
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
IMAGE: ${{ secrets.REGISTRY_URL }}/dev-tools IMAGE: ${{ secrets.REGISTRY_URL }}/dev-tools
VERSION: ${{ github.ref_name }}
DOCKER_BUILDKIT: 1
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- name: Login to registry - name: Login to registry
uses: docker/login-action@v4
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push image
run: | run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login \ IMAGE_TAG="$IMAGE:$VERSION"
${{ secrets.REGISTRY_URL }} \ docker build -t "$IMAGE_TAG" -t "$IMAGE:latest" .
-u ${{ secrets.REGISTRY_USERNAME }} \ docker push "$IMAGE_TAG"
--password-stdin docker push "$IMAGE:latest"
- name: Build image
run: docker build -t $IMAGE:${{ github.ref_name }} .
- name: Push image
run: docker push $IMAGE:${{ github.ref_name }}
- name: Tag & push latest for release tags
run: |
docker tag $IMAGE:${{ github.ref_name }} $IMAGE:latest
docker push $IMAGE:latest

View File

@@ -1,23 +0,0 @@
name: Update Latest Tag
on:
push:
tags:
- v*
jobs:
update-latest:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Update latest tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -f latest
git push origin latest --force