Skip to content

Commit

Permalink
Update docker-image.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ellitedev committed Dec 3, 2023
1 parent 9b6fde7 commit a326336
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
name: Push to registry

on:
push:
branches:
- "main"
create:

jobs:
docker:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Install jq if not present
run: |
if ! command -v jq &> /dev/null
then
sudo apt-get update
sudo apt-get install -y jq
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand All @@ -23,17 +29,31 @@ jobs:
uses: docker/build-push-action@v5
with:
push: true
tags: registry.ellite.dev/raibu-web:latest
tags: registry.ellite.dev/raibu-web:${{ github.ref_name }}
- name: Update latest tag
run: |
LATEST_TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/tags | jq -r '.[].name' | sort -V | tail -n 1)
CURRENT_TAG=${{ github.ref_name }}
SEMVER_REGEX="^v([0-9]+)\.([0-9]+)\.([0-9]+)$"
if [[ ! $CURRENT_TAG =~ $SEMVER_REGEX ]]; then
echo "Error: Tag $CURRENT_TAG does not follow semantic versioning"
exit 1
fi
if [[ "$(printf '%s\n' "$LATEST_TAG" "$CURRENT_TAG" | sort -V | tail -n 1)" == "$CURRENT_TAG" ]]; then
docker tag registry.ellite.dev/raibu-web:${{ github.ref_name }} registry.ellite.dev/raibu-web:latest
docker push registry.ellite.dev/raibu-web:latest
fi
- name: Test image
run: |
docker pull registry.ellite.dev/raibu-web:latest
docker pull registry.ellite.dev/raibu-web:${{ github.ref_name }}
if [ $? -eq 0 ]; then
echo "Image exists"
else
echo "Image does not exist"
exit 1
fi
tarball:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down

0 comments on commit a326336

Please sign in to comment.