From 8dc6a973cec5e911495387683c4f32015513a0de Mon Sep 17 00:00:00 2001 From: Ricardo Mancinas Date: Tue, 13 Oct 2026 15:09:37 -0700 Subject: [PATCH] feat: /version endpoint; fix deploy action inputs - Bake the commit SHA into the image (GIT_SHA build arg) and serve it at /version, so a deploy can be verified end to end. This repo is the dockerloid deploy test service. - cssnr/portainer-stack-deploy-action@v1 reads `endpoint` and `pull`; `endpoint_id` / `pull_image` were silently ignored. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/deploy.yml | 8 +++++--- Dockerfile | 4 ++++ app.py | 7 +++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index db08270..84c81c7 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -51,9 +51,11 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64 + build-args: | + GIT_SHA=${{ github.sha }} deploy: - name: Deploy to Portainer + name: Deploy needs: [build] runs-on: docker container: @@ -68,8 +70,8 @@ jobs: name: ${{ secrets.PORTAINER_STACK_NAME }} file: docker-compose.yml type: file - pull_image: true - endpoint_id: ${{ secrets.PORTAINER_ENDPOINT_ID }} + pull: true + endpoint: ${{ secrets.PORTAINER_ENDPOINT_ID }} env_data: | { "IMAGE": "${{ env.REGISTRY }}/${{ github.repository_owner }}/ascii-art-app:latest" diff --git a/Dockerfile b/Dockerfile index 49c6d58..f7f03a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,10 @@ COPY app.py ascii_engine.py ./ COPY templates ./templates COPY static ./static +# Build provenance, served at /version so deploys can be verified +ARG GIT_SHA=unknown +ENV GIT_SHA=$GIT_SHA + # Expose port EXPOSE 5000 diff --git a/app.py b/app.py index b824a33..4b34439 100644 --- a/app.py +++ b/app.py @@ -1,3 +1,5 @@ +import os + from flask import Flask, jsonify, render_template, request import ascii_engine @@ -15,6 +17,11 @@ def index(): ) +@app.route("/version") +def version(): + return jsonify(gitSha=os.environ.get("GIT_SHA", "unknown")) + + @app.route("/api/random") def api_random(): category = request.args.get("category")