Skip to content

Merge pull request #116 from bestreads/dependabot/npm_and_yarn/axios-… #18

Merge pull request #116 from bestreads/dependabot/npm_and_yarn/axios-…

Merge pull request #116 from bestreads/dependabot/npm_and_yarn/axios-… #18

Workflow file for this run

name: Build and push Docker image
on:
push:
tags:
- 'v*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Check if current tag is the latest version
id: check_latest
run: |
# Get current tag
CURRENT_TAG=${GITHUB_REF#refs/tags/}
# Find highest tag of repo
HIGHEST_TAG=$(git tag -l "v*" | sort -V | tail -n 1)
echo "Current Tag: $CURRENT_TAG"
echo "Highest Tag in Repo: $HIGHEST_TAG"
# Compare and set output
if [ "$CURRENT_TAG" = "$HIGHEST_TAG" ]; then
echo "is_latest=true" >> $GITHUB_OUTPUT
echo "Status: Setting 'latest' tag."
else
echo "is_latest=false" >> $GITHUB_OUTPUT
echo "Status: Not the newest version. Skipping 'latest' tag."
fi
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable=${{ steps.check_latest.outputs.is_latest == 'true' }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}