Check Caddy Releases #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check Caddy Releases and Build Docker Image | |
on: | |
schedule: | |
- cron: '*/5 * * * *' # Runs every 5 minutes | |
workflow_dispatch: # Allows manual triggering | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
check-caddy-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: pip install requests | |
- name: Check and compare Caddy release | |
id: check_release | |
run: python scripts/check_caddy_release.py | |
- name: Build and push Docker image | |
if: env.IS_NEW_RELEASE == 'true' | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/caddy-cloudflare-docker:${{ env.LATEST_VERSION }} | |
ghcr.io/${{ github.repository_owner }}/caddy-cloudflare-docker:latest | |
- name: Clean up Docker images | |
if: env.IS_NEW_RELEASE == 'true' | |
run: | | |
docker rmi ghcr.io/${{ github.repository_owner }}/caddy-cloudflare-docker:${{ env.LATEST_VERSION }} || true | |
docker builder prune --force | |
- name: Update version file | |
if: env.IS_NEW_RELEASE == 'true' | |
run: | | |
echo "{\"version\": \"${LATEST_VERSION}\"}" > version.json | |
git config --global user.name "vkartk" | |
git config --global user.email "[email protected]" | |
git add version.json | |
git commit -m "Update version to ${LATEST_VERSION}" | |
git push |