ci: migrate to Portainer Git stack + registry-pushed image
Some checks failed
Deploy / deploy (push) Failing after 15s
Some checks failed
Deploy / deploy (push) Failing after 15s
- Compose: build → image (Gitea registry ci namespace) - Workflow: build + push UI image + POST Portainer webhook (3-attempt retry) - Drop transient .env file; secrets via Portainer stack Env - Drop auto-version-bump commit-back - Add crowdsec@file to middlewares chain Repo secrets required: REGISTRY_TOKEN, PORTAINER_WEBHOOK_URL. Rollback branch: pre-portainer-migration.
This commit is contained in:
@@ -5,15 +5,9 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
|
||||||
reason:
|
|
||||||
description: "Reason for manual deploy"
|
|
||||||
required: false
|
|
||||||
default: "manual"
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
COMPOSE_PROJECT: outline-sync
|
IMAGE: git.domverse-berlin.eu/ci/outline-sync/ui
|
||||||
COMPOSE_FILE: docker-compose.yml
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
@@ -21,45 +15,26 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
|
|
||||||
- name: Bump patch version
|
- name: Login to Gitea registry
|
||||||
if: github.event_name != 'workflow_dispatch'
|
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.domverse-berlin.eu -u ci --password-stdin
|
||||||
run: |
|
|
||||||
VERSION=$(cat VERSION)
|
|
||||||
MAJOR=$(echo $VERSION | cut -d. -f1)
|
|
||||||
MINOR=$(echo $VERSION | cut -d. -f2)
|
|
||||||
PATCH=$(echo $VERSION | cut -d. -f3)
|
|
||||||
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
|
|
||||||
echo $NEW_VERSION > VERSION
|
|
||||||
echo "APP_VERSION=$NEW_VERSION" >> $GITHUB_ENV
|
|
||||||
git config user.email "ci@domverse-berlin.eu"
|
|
||||||
git config user.name "CI"
|
|
||||||
git add VERSION
|
|
||||||
git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
|
|
||||||
git push
|
|
||||||
|
|
||||||
- name: Write .env
|
- name: Build and push
|
||||||
run: |
|
run: |
|
||||||
cat > .env << EOF
|
docker build --build-arg APP_VERSION="${{ gitea.sha }}" \
|
||||||
OUTLINE_URL=http://outline:3000
|
-t "$IMAGE:latest" -t "$IMAGE:${{ gitea.sha }}" .
|
||||||
OUTLINE_TOKEN=${{ secrets.OUTLINE_TOKEN }}
|
docker push "$IMAGE:latest"
|
||||||
LOCAL_OUTLINE_URL=${{ secrets.LOCAL_OUTLINE_URL }}
|
docker push "$IMAGE:${{ gitea.sha }}"
|
||||||
LOCAL_OUTLINE_TOKEN=${{ secrets.LOCAL_OUTLINE_TOKEN }}
|
|
||||||
LOCAL_OUTLINE_HOST=${{ secrets.LOCAL_OUTLINE_HOST }}
|
|
||||||
TS_AUTHKEY=${{ secrets.TS_AUTHKEY }}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
- name: Deploy with docker compose
|
- name: Trigger Portainer redeploy (retry on transient pull-lease failure)
|
||||||
run: |
|
run: |
|
||||||
APP_VERSION=${APP_VERSION:-$(cat VERSION)}
|
for i in 1 2 3; do
|
||||||
echo "=== Deploying $APP_VERSION (commit ${{ gitea.sha }}) to ${{ gitea.ref_name }} ==="
|
code=$(curl -sk -X POST -o /dev/null -w '%{http_code}' "${{ secrets.PORTAINER_WEBHOOK_URL }}")
|
||||||
docker compose -f "$COMPOSE_FILE" -p "$COMPOSE_PROJECT" build --build-arg APP_VERSION=$APP_VERSION
|
echo "attempt $i -> $code"
|
||||||
docker compose -f "$COMPOSE_FILE" -p "$COMPOSE_PROJECT" up -d --remove-orphans
|
[ "$code" = "204" ] && exit 0
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: Prune dangling images
|
- name: Prune dangling images
|
||||||
run: docker image prune -f
|
run: docker image prune -f
|
||||||
|
|
||||||
- name: Show running containers
|
|
||||||
run: docker compose -f "$COMPOSE_FILE" -p "$COMPOSE_PROJECT" ps
|
|
||||||
|
|||||||
@@ -29,14 +29,11 @@ services:
|
|||||||
- "traefik.http.routers.outline-sync.rule=Host(`sync.domverse-berlin.eu`)"
|
- "traefik.http.routers.outline-sync.rule=Host(`sync.domverse-berlin.eu`)"
|
||||||
- "traefik.http.routers.outline-sync.entrypoints=https"
|
- "traefik.http.routers.outline-sync.entrypoints=https"
|
||||||
- "traefik.http.routers.outline-sync.tls.certresolver=http"
|
- "traefik.http.routers.outline-sync.tls.certresolver=http"
|
||||||
- "traefik.http.routers.outline-sync.middlewares=authentik@docker"
|
- "traefik.http.routers.outline-sync.middlewares=crowdsec@file,authentik@docker"
|
||||||
- "traefik.http.services.outline-sync.loadbalancer.server.port=8080"
|
- "traefik.http.services.outline-sync.loadbalancer.server.port=8080"
|
||||||
|
|
||||||
outline-sync-ui:
|
outline-sync-ui:
|
||||||
build:
|
image: git.domverse-berlin.eu/ci/outline-sync/ui:${TAG:-latest}
|
||||||
context: .
|
|
||||||
args:
|
|
||||||
APP_VERSION: ${APP_VERSION:-dev}
|
|
||||||
container_name: outline-sync-ui
|
container_name: outline-sync-ui
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
Reference in New Issue
Block a user