Aller au contenu

Images de base — Gitea Actions

Ce guide montre comment mettre en place un pipeline d’images de base avec Gitea Actions, le système CI compatible GitHub Actions intégré à Gitea.

.gitea/workflows/base-images.yml
name: Pipeline images de base
on:
push:
branches: [main]
schedule:
- cron: "0 6 * * *" # quotidien à 06h00 UTC
workflow_dispatch:
inputs:
phase:
description: "Phases à exécuter (sync,build,eol-update,status,cleanup)"
required: false
default: "sync,build,status"
jobs:
sync:
name: Synchroniser les miroirs
runs-on: ubuntu-latest
container:
image: registry.gitlab.com/imglife-project/imglife:latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Sync
run: imglife sync
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
IMGLIFE_DOCKER_IO_USERNAME: ${{ vars.DOCKER_HUB_USERNAME }}
IMGLIFE_DOCKER_IO_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
build:
name: Construire les images de base
needs: sync
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configurer Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login au registry
uses: docker/login-action@v3
with:
registry: gitea.example.com
username: ${{ gitea.actor }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Build
run: |
docker buildx create --name imglife-builder --use --bootstrap
imglife --config imglife.yaml build
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
eol-update:
name: Mettre à jour les données EOL
runs-on: ubuntu-latest
if: github.event_name == 'schedule'
container:
image: registry.gitlab.com/imglife-project/imglife:latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Mettre à jour les données EOL
run: imglife eol update
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
- name: Commiter si modifié
run: |
git config user.email "ci-bot@gitea.example.com"
git config user.name "CI Bot"
if git diff --quiet eol-data.yaml; then
echo "Aucun changement"
else
git add eol-data.yaml
git commit -m "chore(lifecycle): update EOL data [skip ci]"
git push
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
status:
name: Générer le rapport d'état
needs: [build]
runs-on: ubuntu-latest
container:
image: registry.gitlab.com/imglife-project/imglife:latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Générer le statut
run: imglife status --output README.md
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
- name: Commiter si modifié
run: |
git config user.email "ci-bot@gitea.example.com"
git config user.name "CI Bot"
if git diff --quiet README.md; then
echo "Aucun changement"
else
git add README.md
git commit -m "chore(status): update status report [skip ci]"
git push
cleanup:
name: Nettoyer les tags obsolètes
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
container:
image: registry.gitlab.com/imglife-project/imglife:latest
env:
CLEANUP_DRY_RUN: "false"
APP_PURGE_KEEP: "3"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cleanup
run: |
ARGS=""
[ "$CLEANUP_DRY_RUN" = "true" ] && ARGS="--dry-run"
imglife app purge --keep "$APP_PURGE_KEEP" $ARGS
imglife cleanup $ARGS
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
registry:
provider: gitea
url: https://gitea.example.com
owner: myorg
repo: base-images
sync:
entries:
- source: docker.io/library/alpine
tag_regex: '^3\.\d+\.\d+$'
keep_last: 3
target: gitea.example.com/myorg/mirrors/alpine
lifecycle:
product: alpine
track: minor
build:
core_version: "1.0.0"
registry: gitea.example.com/myorg/bases
images:
- name: alpine
folder: images/alpine
type: core
mirror_image: gitea.example.com/myorg/mirrors/alpine
mirror_tag: "3.21.3"
version: "3.21.3"
retention:
keep_last: 5
max_age_days: 90
lifecycle:
eol_provider: endoflife
eol_target: git
eol_data_file: eol-data.yaml

Dans Gitea, allez dans Paramètres du dépôt > Secrets et ajoutez :

Secret Description
GITEA_TOKEN Token Gitea avec les scopes package et write:repository
DOCKER_HUB_PASSWORD Mot de passe Docker Hub (pour éviter les limites de taux)