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

156 lines
5.4 KiB
YAML
Raw Normal View History

2024-11-16 07:58:35 +00:00
name: Build and push stable image
2024-11-13 15:59:36 +00:00
on:
2024-11-16 07:58:35 +00:00
schedule:
2024-12-02 17:54:57 +00:00
- cron: '15 10 * * *'
2024-11-16 07:58:35 +00:00
workflow_dispatch:
inputs:
2024-12-03 20:00:44 +00:00
force_rebuild:
description: 'rebuild'
type: boolean
required: true
2024-11-13 15:59:36 +00:00
env:
2024-11-24 08:09:21 +00:00
DOTCLEAR_IMAGE: docker-dotclear
2024-11-13 17:00:56 +00:00
DOTCLEAR_CANAL: stable
2024-11-24 08:09:21 +00:00
DOCKER_NAMESPACE: jcpd
2024-11-13 15:59:36 +00:00
jobs:
2024-12-02 23:53:21 +00:00
check_image:
2024-11-16 08:13:02 +00:00
name: Check and compare official Dotclear version
2024-11-16 07:58:35 +00:00
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
version: ${{ steps.dotclear.outputs.tag }}
2024-12-06 23:04:35 +00:00
has_image: ${{ steps.registry.outputs.image_exists }}
has_branch: ${{ steps.branch.outputs.exists }}
2024-11-16 07:58:35 +00:00
steps:
- name: Get last dotclear repository tag
2024-11-16 07:58:35 +00:00
id: dotclear
uses: oprypin/find-latest-tag@v1
with:
repository: dotclear/dotclear
- name: version
2024-11-16 07:58:35 +00:00
run: |
SUMMARY=$'Last Dotclear repository tag is ${{ steps.dotclear.outputs.tag }}.'
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
2024-11-16 07:58:35 +00:00
2024-12-02 23:40:27 +00:00
- name: Check registry image
2024-12-02 23:43:49 +00:00
id: registry
2024-12-02 23:40:27 +00:00
uses: k4kratik/container-image-check-custom-action@v4
with:
type: dockerhub
2024-12-02 23:47:37 +00:00
container_repo_name: ${{ env.DOTCLEAR_IMAGE }}
image_tag: ${{ steps.dotclear.outputs.tag }}
2024-12-02 23:40:27 +00:00
dockerhub_username: ${{ secrets.DOCKER_USERNAME }}
dockerhub_token: ${{ secrets.DOCKER_TOKEN }}
2024-11-16 07:58:35 +00:00
2024-12-02 23:05:09 +00:00
- name: notfound
2024-12-02 23:43:49 +00:00
if: (steps.registry.outputs.image_exists == 'false')
2024-12-02 23:05:09 +00:00
run: |
SUMMARY=$'Image ${{ env.DOCKER_NAMESPACE }}/${{ env.DOTCLEAR_IMAGE }}:${{ steps.dotclear.outputs.tag }} not found.'
2024-12-02 23:05:09 +00:00
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
- name: found
2024-12-02 23:43:49 +00:00
if: (steps.registry.outputs.image_exists == 'true')
2024-12-02 23:05:09 +00:00
run: |
SUMMARY=$'Image ${{ env.DOCKER_NAMESPACE }}/${{ env.DOTCLEAR_IMAGE }}:${{ steps.dotclear.outputs.tag }} found.'
2024-12-02 23:05:09 +00:00
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
- name: Check repository branch
id: branch
uses: GuillaumeFalourd/branch-exists@v1.1
with:
branch: ${{ steps.dotclear.outputs.tag }}
do_image:
2024-12-06 23:04:35 +00:00
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
2024-12-06 23:04:35 +00:00
runs-on: ubuntu-latest
permissions:
packages: write
2024-12-06 23:10:14 +00:00
contents: write
attestations: write
id-token: write
2024-12-06 23:04:35 +00:00
steps:
- name: Check out the repo
if: ((needs.check_image.outputs.has_branch == 'false') || (github.event.inputs.force_rebuild == 'true'))
2024-12-06 23:04:35 +00:00
uses: actions/checkout@v4
- name: Create repository branch
if: ((needs.check_image.outputs.has_branch == 'false') || (github.event.inputs.force_rebuild == 'true'))
2024-12-06 23:04:35 +00:00
id: create
2024-12-07 13:45:07 +00:00
uses: peterjgrainger/action-create-branch@v3.0.0
2024-12-06 23:04:35 +00:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: ${{ needs.check_image.outputs.version }}
- name: notcreated
if: ((needs.check_image.outputs.has_branch == 'false') || (github.event.inputs.force_rebuild == 'true')) && (steps.create.outputs.created == 'false')
2024-12-06 23:04:35 +00:00
run: |
2024-12-06 23:12:41 +00:00
SUMMARY=$'Branch ${{ needs.check_image.outputs.version }} has not been created.'
2024-12-06 23:04:35 +00:00
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
- name: created
if: ((needs.check_image.outputs.has_branch == 'false') || (github.event.inputs.force_rebuild == 'true')) && (steps.create.outputs.created == 'true')
2024-12-06 23:04:35 +00:00
run: |
2024-12-06 23:12:41 +00:00
SUMMARY=$' Branch ${{ needs.check_image.outputs.version }} has been created.'
2024-12-06 23:04:35 +00:00
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
2024-11-13 15:59:36 +00:00
- name: Check out the repo
uses: actions/checkout@v4
with:
2024-12-09 23:22:40 +00:00
ref: ${{ needs.check_image.outputs.version }}
2024-11-13 15:59:36 +00:00
- 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 }}
2024-11-24 08:09:21 +00:00
- name: Log in to Github registry
2024-11-24 08:25:08 +00:00
uses: docker/login-action@v3
2024-11-24 08:09:21 +00:00
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 }}'
2024-11-13 17:00:56 +00:00
- name: Build and push images
2024-11-13 15:59:36 +00:00
uses: docker/build-push-action@v6
with:
context: .
sbom: true
push: true
2024-11-13 17:00:56 +00:00
tags: |
2024-12-02 23:53:21 +00:00
${{ env.DOCKER_NAMESPACE }}/${{ env.DOTCLEAR_IMAGE }}:${{ needs.check_image.outputs.version }}
2024-11-24 08:09:21 +00:00
${{ env.DOCKER_NAMESPACE }}/${{ env.DOTCLEAR_IMAGE }}:latest
2024-12-02 23:53:21 +00:00
ghcr.io/${{ env.GITHUB_REPOSITORY }}:${{ needs.check_image.outputs.version }}
2024-11-24 08:09:21 +00:00
ghcr.io/${{ env.GITHUB_REPOSITORY }}:latest
2024-11-13 15:59:36 +00:00
build-args: CANAL=${{ env.DOTCLEAR_CANAL }}
2024-11-24 08:47:32 +00:00
platforms: linux/386,linux/amd64,linux/arm64,linux/arm/V7
cache-from: type=gha
cache-to: type=gha,mode=max
2024-11-16 12:38:33 +00:00
- 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
2024-12-02 23:53:21 +00:00
message: Images __${{ env.DOTCLEAR_IMAGE }}:latest__ and __${{ env.DOTCLEAR_IMAGE }}:${{ needs.check_image.outputs.version }}__ successfully generated.