This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
name: Build et push de l'image Docker
|
||||
name: Build et push Docker
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -6,10 +6,6 @@ on:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -18,33 +14,50 @@ jobs:
|
||||
- name: Récupérer le dépôt
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Préparer le nom de l'image
|
||||
- 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=${GITHUB_SHA::12}" >> "$GITHUB_ENV"
|
||||
echo "SHORT_SHA=$SHORT_SHA" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Vérifier Docker
|
||||
shell: bash
|
||||
run: |
|
||||
docker version
|
||||
docker buildx version
|
||||
echo "Image : $IMAGE_NAME"
|
||||
echo "Commit : $SHORT_SHA"
|
||||
|
||||
- name: Connexion au registre
|
||||
shell: bash
|
||||
env:
|
||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||
run: |
|
||||
echo '${{ secrets.GITEA_TOKEN }}' \
|
||||
printf '%s' "$REGISTRY_TOKEN" \
|
||||
| docker login "$REGISTRY" \
|
||||
--username '${{ gitea.actor }}' \
|
||||
--username "$GITHUB_ACTOR" \
|
||||
--password-stdin
|
||||
|
||||
- name: Construire et pousser
|
||||
- name: Construire l'image
|
||||
shell: bash
|
||||
run: |
|
||||
docker buildx build \
|
||||
docker build \
|
||||
--pull \
|
||||
--push \
|
||||
--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"
|
||||
Reference in New Issue
Block a user