Files
Reskreen/.gitea/workflows/docker_builder_latest.yaml
2024-10-30 10:46:41 +01:00

100 lines
3.1 KiB
YAML

name: Build and Push Docker Image
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build:
if: github.actor != 'github-actions[bot]'
runs-on: self-hosted
container:
image: alpine:latest
steps:
- name: Set up and Install Dependencies
run: |
apk update && apk add --no-cache mariadb-connector-c-dev gcc musl-dev nodejs npm git docker libffi-dev libffi curl libxml2 libxslt
- name: Check out repository code
uses: actions/checkout@v4
- name: Increment version +1
id: increment_version
shell: sh
run: |
# Lire le fichier VERSION
version=$(cat VERSION)
echo "Current version: $version"
# Extraire les parties majeure, mineure et patch
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
patch=$(echo $version | cut -d. -f3)
# Incrémenter la version patch
patch=$((patch + 1))
# Créer la nouvelle version
new_version="$major.$minor.$patch"
echo "New version: $new_version"
# Écrire la nouvelle version dans le fichier VERSION
echo $new_version > VERSION
# Exporter la nouvelle version comme variable de sortie
echo "::set-output name=new_version::$new_version"
echo "::set-output name=major::$major"
- name: Commit and push new version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "bot@resk-u.ch"
# Ajouter et commit le fichier VERSION
git add VERSION
git commit -m "Increment version to ${{ steps.increment_version.outputs.new_version }}"
# Push les modifications
git push origin master
- name: Run Changelog CI
uses: saadmk11/changelog-ci@v1.1.2
with:
release_version: ${{ steps.increment_version.outputs.new_version }}
- name: Use server_config_default as primary
run: mv /workspace/CLERC/Reskreen/config/server_config_default.py /workspace/CLERC/Reskreen/config/server_config.py
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Registry
uses: docker/login-action@v3
with:
registry: gitea.prod.resk-u.ch
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
gitea.prod.resk-u.ch/clerc/reskreen:latest
gitea.prod.resk-u.ch/clerc/reskreen:${{ steps.increment_version.outputs.major }}
- name: Call webhook $ {{ vars.CLERC_PROD_WEBHOOK}}
run: |
echo "Exécution de la commande: curl ${{ vars.CLERC_PROD_WEBHOOK }}"?repo=reskreen
curl ${{ vars.CLERC_PROD_WEBHOOK }}?repo=reskreen