Actualiser .gitea/workflows/build-push.yaml
This commit is contained in:
@@ -8,10 +8,11 @@ on:
|
||||
env:
|
||||
IMAGE_NAME: public/blueskycrossposter
|
||||
TAG: latest
|
||||
REGISTRY_USER: eric@coissac.eu
|
||||
IMAGE_REGISTRY: niepce.petite-maison-orange.fr
|
||||
REGISTRY_USER: eric@coissac.eu
|
||||
REGISTRY_PASSWORD: ${{ secrets.NIEPCETOKEN }}
|
||||
CHECK: https://haoma.petite-maison-orange.fr/ping/814308c3-d90c-4511-b236-c40b37a5ad23
|
||||
RELEASE_FILE: bluesky_crossposter_latest.txt
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -24,11 +25,10 @@ jobs:
|
||||
${{ env.CHECK }}/start
|
||||
shell: bash
|
||||
|
||||
- name: install Buildah
|
||||
- name: install podman
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y buildah \
|
||||
podman
|
||||
apt-get install -y podman
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
@@ -36,24 +36,49 @@ jobs:
|
||||
- name: Build image starting
|
||||
run: |
|
||||
curl -fsS -m 10 --retry 5 \
|
||||
--data-raw "Buildind docker image for $(cat bluesky_crossposter_latest.txt)" \
|
||||
--data-raw "Buildind docker image for $(cat ${{ env.RELEASE_FILE }})" \
|
||||
${{ env.CHECK }}/log
|
||||
shell: bash
|
||||
|
||||
- name: Set up Buildah
|
||||
id: build-image
|
||||
uses: redhat-actions/buildah-build@v2
|
||||
with:
|
||||
image: ${{ env.IMAGE_NAME }}
|
||||
tags: latest ${{ github.sha }}
|
||||
containerfiles: |
|
||||
./Dockerfile
|
||||
- name: Read version file
|
||||
id: version
|
||||
run: |
|
||||
# Lire le contenu du fichier et supprimer les espaces/retours chariots
|
||||
SOFTVERSION=$(cat ${{ env.RELEASE_FILE }} | tr -d ' \n')
|
||||
# Stocker la valeur dans une variable d'environnement
|
||||
echo "SOFTVERSION=$SOFTVERSION" >> $GITEA_ENV
|
||||
|
||||
- name: Add PMO version tag
|
||||
run: |
|
||||
echo "IMAGE_TAGS=${{ env.IMAGE_TAGS }} pmo-${{ env.SOFTVERSION }}" >> $GITEA_ENV
|
||||
|
||||
- name: Podman login
|
||||
run: |
|
||||
podman login ${{ env.IMAGE_REGISTRY }} \
|
||||
-u ${{ env.REGISTRY_USER }} \
|
||||
-p ${{ env.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Build and tag image
|
||||
run: |
|
||||
tags=(${{ env.IMAGE_TAGS }})
|
||||
sep=""
|
||||
if [[ -n "${tags[1]}" ]] ; then
|
||||
sep=":"
|
||||
fi
|
||||
image=${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}${sep}${tags[0]}
|
||||
docker build -t ${image} .
|
||||
docker save ${image} -o image.tar
|
||||
podman load -i image.tar
|
||||
for tag in "${tags[@]:1}" ; do
|
||||
podman tag ${image} \
|
||||
${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${tag}
|
||||
done
|
||||
|
||||
- name: Canceled building
|
||||
if: cancelled()
|
||||
run: |
|
||||
curl -fsS -m 10 --retry 5 \
|
||||
--data-raw "Building image cancelled for $(cat bluesky_crossposter_latest.txt)" \
|
||||
--data-raw "Building image cancelled for $(cat ${{ env.RELEASE_FILE }})" \
|
||||
${{ env.CHECK }}/fail
|
||||
exit 1
|
||||
shell: bash
|
||||
@@ -62,26 +87,23 @@ jobs:
|
||||
if: failure()
|
||||
run: |
|
||||
curl -fsS -m 10 --retry 5 \
|
||||
--data-raw "Failed to build docker image for $(cat bluesky_crossposter_latest.txt)" \
|
||||
--data-raw "Failed to build docker image for $(cat ${{ env.RELEASE_FILE }})" \
|
||||
${{ env.CHECK }}/fail
|
||||
exit 1
|
||||
shell: bash
|
||||
|
||||
- name: Push to Niepce Container Repository
|
||||
id: push-to-niepce
|
||||
uses: redhat-actions/push-to-registry@v2
|
||||
with:
|
||||
image: ${{ steps.build-image.outputs.image }}
|
||||
tags: ${{ steps.build-image.outputs.tags }}
|
||||
registry: ${{ env.IMAGE_REGISTRY }}
|
||||
username: ${{ env.REGISTRY_USER }}
|
||||
password: ${{ env.REGISTRY_PASSWORD }}
|
||||
- name: Push image to registry
|
||||
run: |
|
||||
tags=(${{ env.IMAGE_TAGS }})
|
||||
for tag in "${tags[@]}" ; do
|
||||
podman push ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:$tag
|
||||
done
|
||||
|
||||
- name: Push image failed
|
||||
if: failure()
|
||||
run: |
|
||||
curl -fsS -m 10 --retry 5 \
|
||||
--data-raw "Failed to push docker image for $(cat bluesky_crossposter_latest.txt)" \
|
||||
--data-raw "Failed to push docker image for $(cat ${{ env.RELEASE_FILE }})" \
|
||||
${{ env.CHECK }}/fail
|
||||
exit 1
|
||||
shell: bash
|
||||
@@ -89,16 +111,7 @@ jobs:
|
||||
- name: End of the job
|
||||
run: |
|
||||
curl -fsS -m 10 --retry 5 \
|
||||
--data-raw "Build docker image for $(cat bluesky_crossposter_latest.txt)" \
|
||||
--data-raw "Build docker image for $(cat ${{ env.RELEASE_FILE }})" \
|
||||
${{ env.CHECK }}
|
||||
shell: bash
|
||||
- name: Canceled building
|
||||
if: cancelled()
|
||||
run: |
|
||||
curl -fsS -m 10 --retry 5 \
|
||||
--data-raw "Building image cancelled for $(cat bluesky_crossposter_latest.txt)" \
|
||||
${{ env.CHECK }}/fail
|
||||
exit 1
|
||||
shell: bash
|
||||
|
||||
|
||||
Reference in New Issue
Block a user