name: Rollback (develop) # Trigger manually from the Gitea Actions UI. # Leave "sha" empty to roll back to the previous deploy. # Fill "sha" in (short 7-char form, e.g. a3f9c21) to roll back to the newest # build for that commit. Build tags include a UTC timestamp and commit SHA. on: workflow_dispatch: inputs: sha: description: 'Short commit SHA to roll back to (empty = previous deploy)' required: false default: '' jobs: rollback: runs-on: ubuntu-latest steps: - name: Determine target tag run: | if [ -n "${{ gitea.event.inputs.sha }}" ]; then SHA="${{ gitea.event.inputs.sha }}" TAG=$(docker images robot-market --format '{{.Tag}}' \ | grep -E "-${SHA}$" \ | sort -r \ | head -n 1) # Keep accepting legacy SHA-only tags created before timestamped tags. if [ -z "$TAG" ]; then TAG="$SHA" fi else TAG=$(grep IMAGE_TAG /opt/robot-market-front/.env.previous | cut -d= -f2) fi echo "Rolling back to: $TAG" echo "IMAGE_TAG=$TAG" > /opt/robot-market-front/.env - name: Verify that image actually exists locally run: | TAG=$(grep IMAGE_TAG /opt/robot-market-front/.env | cut -d= -f2) docker image inspect robot-market:$TAG > /dev/null - name: Redeploy target image run: | docker compose --env-file /opt/robot-market-front/.env \ -f /opt/robot-market-front/docker-compose.yml \ up -d --force-recreate