docker-dotclear/.github/workflows/release_stable.yml

156 lines
5.3 KiB
YAML

name: Build and push stable image
on:
schedule:
- cron: '15 10 * * *'
workflow_dispatch:
inputs:
force_rebuild:
description: 'rebuild'
type: boolean
required: true
env:
DOTCLEAR_IMAGE: docker-dotclear
DOTCLEAR_CANAL: stable
DOTCLEAR_URL: https://download.dotclear.org/versions.xml
DOCKER_NAMESPACE: jcpd
jobs:
check_image:
name: Check and compare official Dotclear version
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
version: ${{ steps.dotclear.outputs.version }}
has_image: ${{ steps.registry.outputs.image_exists }}
has_branch: ${{ steps.branch.outputs.exists }}
steps:
- name: Download and parse last version
id: dotclear
run: |
curl -sSL https://bit.ly/install-xq | sudo bash
curl -fsSL -o versions.xml ${{ env.DOTCLEAR_URL }}
echo version=$(cat versions.xml | xq -x "//release[@name='${{ env.DOTCLEAR_CANAL }}']/@version") >> $GITHUB_OUTPUT
- name: Check registry image
id: registry
uses: k4kratik/container-image-check-custom-action@v4
with:
type: dockerhub
container_repo_name: ${{ env.DOTCLEAR_IMAGE }}
image_tag: ${{ steps.dotclear.outputs.version }}
dockerhub_username: ${{ secrets.DOCKER_USERNAME }}
dockerhub_token: ${{ secrets.DOCKER_TOKEN }}
- name: Check repository branch
id: branch
uses: GuillaumeFalourd/branch-exists@v1.1
with:
branch: ${{ steps.dotclear.outputs.version }}
- name: notfound
if: (steps.registry.outputs.image_exists == 'false')
run: |
SUMMARY=$'Image ${{ env.DOCKER_NAMESPACE }}/${{ env.DOTCLEAR_IMAGE }}:${{ steps.dotclear.outputs.version }} not found.'
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
- name: found
if: (steps.registry.outputs.image_exists == 'true')
run: |
SUMMARY=$'Image ${{ env.DOCKER_NAMESPACE }}/${{ env.DOTCLEAR_IMAGE }}:${{ steps.dotclear.outputs.version }} found.'
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
do_branch:
needs: check_image
if: ((needs.check_image.outputs.has_branch == 'false') || (github.event.inputs.force_rebuild == 'true'))
name: Build and push latest and versionned images
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Create repository branch
id: create
uses: peterjgrainger/action-create-branch@v2.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: ${{ needs.check_image.outputs.version }}
- name: notfound
if: (steps.create.outputs.created == 'false')
run: |
SUMMARY=$'Branch ${{ steps.dotclear.outputs.version }} has not been created.'
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
- name: found
if: (steps.create.outputs.created == 'true')
run: |
SUMMARY=$' Branch ${{ steps.dotclear.outputs.version }} has been created.'
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
do_image:
needs: check_image
if: ((needs.check_image.outputs.has_image == 'false') || (github.event.inputs.force_rebuild == 'true'))
name: Build and push latest and versionned images
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Log in to Github registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: set lower case github repository
run: |
echo "GITHUB_REPOSITORY=${REPO,,}" >>${GITHUB_ENV}
env:
REPO: '${{ github.repository }}'
- name: Build and push images
uses: docker/build-push-action@v6
with:
context: .
sbom: true
push: true
tags: |
${{ env.DOCKER_NAMESPACE }}/${{ env.DOTCLEAR_IMAGE }}:${{ needs.check_image.outputs.version }}
${{ env.DOCKER_NAMESPACE }}/${{ env.DOTCLEAR_IMAGE }}:latest
ghcr.io/${{ env.GITHUB_REPOSITORY }}:${{ needs.check_image.outputs.version }}
ghcr.io/${{ env.GITHUB_REPOSITORY }}:latest
build-args: CANAL=${{ env.DOTCLEAR_CANAL }}
platforms: linux/386,linux/amd64,linux/arm64,linux/arm/V7
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Send Telegram Message Ok
uses: appleboy/telegram-action@master
env:
GITHUB_CONTEXT: ${{toJSON(github)}}
with:
to: ${{ secrets.TELEGRAM_ID }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: Images __${{ env.DOTCLEAR_IMAGE }}:latest__ and __${{ env.DOTCLEAR_IMAGE }}:${{ needs.check_image.outputs.version }}__ successfully generated.