Skip to content

auto_image

auto_image #14

Workflow file for this run

name: auto_image
on:
schedule:
- cron: '0 0 8 * *'
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract and increment version
id: extract_version
run: |
REPO=${{ secrets.DOCKERHUB_USERNAME }}/mosdns
LATEST_VERSION=$(curl -s "https://hub.docker.com/v2/repositories/$REPO/tags/?page_size=100" | grep -oP '"name":\s*"\K[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n 1)
LATEST_VERSION=${LATEST_VERSION:-"1.0.0"}
VERSION=$(echo $LATEST_VERSION | awk -F. -v OFS=. '{$NF += 1 ; print}')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/mosdns:${{ env.VERSION }}
${{ secrets.DOCKERHUB_USERNAME }}/mosdns:latest