Files
runners-images/.gitea/workflows/build-image.yml
T
jean.staffe b5a08d6983
Build et push Docker / build (push) Failing after 32s
Update .gitea/workflows/build-image.yml
2026-07-25 22:08:51 +00:00

63 lines
1.5 KiB
YAML

name: Build et push Docker
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Récupérer le dépôt
uses: actions/checkout@v4
- name: Préparer les variables
shell: bash
run: |
REPOSITORY_LOWER="$(printf '%s' "$GITHUB_REPOSITORY" \
| tr '[:upper:]' '[:lower:]')"
SHORT_SHA="$(printf '%s' "$GITHUB_SHA" | cut -c1-12)"
echo "REGISTRY=git.jst.ovh" >> "$GITHUB_ENV"
echo "IMAGE_NAME=git.jst.ovh/$REPOSITORY_LOWER" >> "$GITHUB_ENV"
echo "SHORT_SHA=$SHORT_SHA" >> "$GITHUB_ENV"
- name: Vérifier Docker
shell: bash
run: |
docker version
echo "Image : $IMAGE_NAME"
echo "Commit : $SHORT_SHA"
- name: Connexion au registre
shell: bash
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: |
printf '%s' "$REGISTRY_TOKEN" \
| docker login "$REGISTRY" \
--username "$GITHUB_ACTOR" \
--password-stdin
- name: Construire l'image
shell: bash
run: |
docker build \
--pull \
--tag "$IMAGE_NAME:latest" \
--tag "$IMAGE_NAME:sha-$SHORT_SHA" \
.
- name: Publier l'image latest
shell: bash
run: |
docker push "$IMAGE_NAME:latest"
- name: Publier l'image du commit
shell: bash
run: |
docker push "$IMAGE_NAME:sha-$SHORT_SHA"