name: Build and Push Docker Image on: push: branches: - main # Changez cela si votre branche principale a un autre nom env: IMAGE_NAME: public/calibre-web TAG: latest REGISTRY_USER: eric@coissac.eu IMAGE_REGISTRY: niepce.petite-maison-orange.fr REGISTRY_PASSWORD: ${{ secrets.NIEPCETOKEN }} CHECK: https://haoma.petite-maison-orange.fr/ping/7e80fab1-f1ed-4ece-81aa-cf9061cda5c4 RELEASE_FILE: calibre_web_latest.txt jobs: build: runs-on: ubuntu-latest steps: - name: Start the job run: | curl -fsS -m 10 --retry 5 \ ${{ env.CHECK }}/start shell: bash - name: install Buildah run: | apt-get update apt-get install -y buildah \ podman - name: Checkout code uses: actions/checkout@v4 - name: Build image starting run: | curl -fsS -m 10 --retry 5 \ --data-raw "Buildind docker image for $(cat ${{ env.RELEASE_FILE }})" \ ${{ env.CHECK }}/log shell: bash - name: Read version file id: version run: | # Lire le contenu du fichier et supprimer les espaces/retours chariots VERSION=$(cat ${{ env.RELEASE_FILE }} | tr -d ' \n') # Stocker la valeur dans une variable d'environnement echo "VERSION=$VERSION" >> $GITEA_ENV - name: Configure Buildah storage run: | sudo mkdir -p /var/lib/containers/storage echo -e "[storage]\ndriver = \"overlay\"" | sudo tee /etc/containers/storage.conf sudo buildah --storage-driver overlay2 info - name: Build image using buildah id: build-image uses: redhat-actions/buildah-build@v2 with: image: ${{ env.IMAGE_NAME }} tags: latest pmo-${{ env.VERSION }} layers: true containerfiles: | ./Dockerfile extra-args: --storage-driver=overlay --isolation=chroot env: STORAGE_DRIVER: overlay BUILDAH_ISOLATION: "chroot" - name: Canceled building if: cancelled() run: | curl -fsS -m 10 --retry 5 \ --data-raw "Building image cancelled for $(cat ${{ env.RELEASE_FILE }})" \ ${{ env.CHECK }}/fail exit 1 shell: bash - name: Build image failed if: failure() run: | curl -fsS -m 10 --retry 5 \ --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 failed if: failure() run: | curl -fsS -m 10 --retry 5 \ --data-raw "Failed to push docker image for $(cat bluesky_crossposter_latest.txt)" \ ${{ env.CHECK }}/fail exit 1 shell: bash - name: End of the job run: | curl -fsS -m 10 --retry 5 \ --data-raw "Build docker image for $(cat bluesky_crossposter_latest.txt)" \ ${{ 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