50 lines
1.2 KiB
YAML
50 lines
1.2 KiB
YAML
name: Build et push de l'image Docker
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Récupérer le dépôt
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Préparer le nom de l'image
|
|
shell: bash
|
|
run: |
|
|
REPOSITORY_LOWER="$(printf '%s' "$GITHUB_REPOSITORY" \
|
|
| tr '[:upper:]' '[:lower:]')"
|
|
|
|
echo "REGISTRY=git.jst.ovh" >> "$GITHUB_ENV"
|
|
echo "IMAGE_NAME=git.jst.ovh/$REPOSITORY_LOWER" >> "$GITHUB_ENV"
|
|
echo "SHORT_SHA=${GITHUB_SHA::12}" >> "$GITHUB_ENV"
|
|
|
|
- name: Vérifier Docker
|
|
run: |
|
|
docker version
|
|
docker buildx version
|
|
|
|
- name: Connexion au registre
|
|
run: |
|
|
echo '${{ secrets.GITEA_TOKEN }}' \
|
|
| docker login "$REGISTRY" \
|
|
--username '${{ gitea.actor }}' \
|
|
--password-stdin
|
|
|
|
- name: Construire et pousser
|
|
run: |
|
|
docker buildx build \
|
|
--pull \
|
|
--push \
|
|
--tag "$IMAGE_NAME:latest" \
|
|
--tag "$IMAGE_NAME:sha-$SHORT_SHA" \
|
|
. |