Skip to content

why not running!

why not running! #5

name: Docker Image CI
on:
workflow_dispatch:
schedule:
- cron: '4 20 * * 4'
push:
branches: [ main ]
jobs:
latest_version:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.fetch_tag.outputs.tag }}
steps:
- name: Fetch latest version
id: fetch_tag
run: |
API_TOKEN="${{ secrets.GITHUB_TOKEN }}"
REPO_OWNER="just-containers"
REPO_NAME="s6-overlay"
tag_name=$(curl -sH "Authorization: token $API_TOKEN" https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/latest | jq -r '.tag_name' | cut -c2-)
echo "tag=$tag_name" >> $GITHUB_OUTPUT
echo "tag=$tag_name"
check_image_tag:
runs-on: ubuntu-latest
needs: latest_version
outputs:
image_exists: ${{ steps.check_image.outputs.image_exists }}
steps:
- name: Check image tag exists
id: check_image
env:
LATEST_TAG: ${{needs.latest_version.outputs.tag}}
run: |
IMAGE_NAME="hakindazz/s6-overlay-base"
docker pull "$IMAGE_NAME:$LATEST_TAG" &> /dev/null
if [ $? -eq 0 ]; then
echo "image_exists=true" >> $GITHUB_OUTPUT
else
echo "image_exists=false" >> $GITHUB_OUTPUT
fi
build-and-push:
runs-on: ubuntu-latest
needs: [latest_version, check_image_tag]
if: "!needs.check_image_tag.outputs.image_exists"
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: |
hakindazz/s6-overlay-base:latest
hakindazz/s6-overlay-base:${{ needs.latest_version.outputs.tag }}