mirror of
https://codeberg.org/angestoepselt/homepage.git
synced 2025-05-24 14:46:16 +00:00
This commit reworks the CI setup to use a single staging environment and run it for every branch. That means the staging URL will always contain the most recent changes, independent of the branch.
64 lines
1.7 KiB
YAML
64 lines
1.7 KiB
YAML
kind: pipeline
|
|
name: homepage
|
|
|
|
steps:
|
|
- name: build sites
|
|
image: gcr.io/kaniko-project/executor:v1.9.0-debug
|
|
environment:
|
|
DOCKER_USERNAME:
|
|
from_secret: registry_username
|
|
DOCKER_PASSWORD:
|
|
from_secret: registry_password
|
|
DOCKER_REGISTRY: codeberg.org
|
|
IMAGE_BASE: codeberg.org/angestoepselt/homepage
|
|
commands:
|
|
- echo "{\"auths\":{\"$DOCKER_REGISTRY\":{\"username\":\"$DOCKER_USERNAME\",\"password\":\"$DOCKER_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
|
- if [ "$DRONE_BRANCH" = "main" ]; then export TAG="main"; else export TAG="stage"; fi
|
|
- /kaniko/executor --cache --cache-dir=/cache --context . --destination "$IMAGE_BASE/angestoepselt:$TAG" --build-arg SITE=angestoepselt
|
|
- /kaniko/executor --cache --cache-dir=/cache --context . --destination "$IMAGE_BASE/coderdojo:$TAG" --build-arg SITE=coderdojo
|
|
|
|
- name: deploy staging environment
|
|
image: plugins/webhook
|
|
settings:
|
|
urls:
|
|
from_secret: portainer_stage_url
|
|
depends_on:
|
|
- build sites
|
|
when:
|
|
branch:
|
|
exclude:
|
|
- main
|
|
|
|
- name: deploy production environment
|
|
image: plugins/webhook
|
|
settings:
|
|
urls:
|
|
from_secret: portainer_main_url
|
|
when:
|
|
branch:
|
|
- main
|
|
|
|
- name: send notification
|
|
image: plugins/webhook
|
|
settings:
|
|
urls:
|
|
from_secret: DRONE_WEBHOOK_ENDPOINT
|
|
username: drone
|
|
password:
|
|
from_secret: DRONE_WEBHOOK_SECRET
|
|
content_type: application/json
|
|
template: |
|
|
{
|
|
"branch": "{{ build.branch }}",
|
|
"author": "{{ build.author }}",
|
|
"event": "{{ build.event }}",
|
|
"status": "{{ build.status }}",
|
|
"owner": "{{ repo.owner }}",
|
|
"repo": "{{ repo.name }}"
|
|
}
|
|
depends_on:
|
|
- deploy production environment
|
|
|
|
trigger:
|
|
event:
|
|
- push
|