2021-07-04 06:22:25 +00:00
|
|
|
---
|
|
|
|
kind: pipeline
|
2023-07-01 16:21:19 +00:00
|
|
|
name: generate-blog
|
2021-07-04 06:22:25 +00:00
|
|
|
|
2021-07-04 07:54:30 +00:00
|
|
|
clone:
|
|
|
|
depth: 1
|
|
|
|
|
2021-07-04 06:22:25 +00:00
|
|
|
steps:
|
2023-07-01 15:47:58 +00:00
|
|
|
- name: update-submodules
|
2021-07-04 06:35:32 +00:00
|
|
|
image: alpine/git
|
|
|
|
commands:
|
|
|
|
- git submodule update --init --recursive
|
|
|
|
|
2023-07-01 15:47:58 +00:00
|
|
|
- name: generate-blog
|
2021-07-04 06:22:25 +00:00
|
|
|
image: plugins/hugo
|
|
|
|
settings:
|
|
|
|
hugo_version: 0.84.4
|
|
|
|
validate: true
|
2021-07-04 06:24:48 +00:00
|
|
|
pull: always
|
2023-07-02 22:05:28 +00:00
|
|
|
depends_on:
|
|
|
|
- update-submodules
|
2021-07-04 06:59:25 +00:00
|
|
|
|
2023-07-01 15:47:58 +00:00
|
|
|
- name: clean-up-images
|
|
|
|
image: alpine
|
2021-07-04 06:59:25 +00:00
|
|
|
commands:
|
2021-07-04 08:34:04 +00:00
|
|
|
- rm -rf public/images/*
|
2023-07-02 22:05:28 +00:00
|
|
|
depends_on:
|
|
|
|
- generate-blog
|
2021-07-04 06:59:25 +00:00
|
|
|
|
2023-07-01 15:47:58 +00:00
|
|
|
- name: build-container
|
|
|
|
image: plugins/docker
|
|
|
|
settings:
|
|
|
|
registry: scm.project42.io
|
|
|
|
username:
|
|
|
|
from_secret: registry_username
|
|
|
|
password:
|
|
|
|
from_secret: registry_password
|
|
|
|
repo: scm.project42.io/elia/blog
|
|
|
|
dry_run: false
|
|
|
|
squash: true
|
|
|
|
tags:
|
|
|
|
- "${DRONE_COMMIT_SHA:0:8}"
|
2023-07-03 21:33:25 +00:00
|
|
|
depends_on:
|
2024-01-20 00:21:37 +00:00
|
|
|
- clean-up-images
|
2023-07-05 22:01:47 +00:00
|
|
|
when:
|
|
|
|
event:
|
|
|
|
exclude:
|
|
|
|
- promote
|
2023-07-03 21:33:25 +00:00
|
|
|
|
|
|
|
- name: trivy-scan
|
|
|
|
image: scm.project42.io/elia/tricks:latest
|
2023-07-05 21:53:11 +00:00
|
|
|
environment:
|
|
|
|
REGISTRY_USERNAME:
|
|
|
|
from_secret: registry_username
|
|
|
|
REGISTRY_PASSWORD:
|
|
|
|
from_secret: registry_password
|
2023-07-03 21:33:25 +00:00
|
|
|
commands:
|
2024-01-20 00:21:37 +00:00
|
|
|
- trivy image --image-src remote --exit-code 0 --username "$REGISTRY_USERNAME" --password "$REGISTRY_PASSWORD" "scm.project42.io/elia/blog:${DRONE_COMMIT_SHA:0:8}"
|
2023-07-03 21:33:25 +00:00
|
|
|
depends_on:
|
|
|
|
- build-container
|
2023-07-05 22:01:47 +00:00
|
|
|
when:
|
|
|
|
event:
|
|
|
|
exclude:
|
|
|
|
- promote
|
2023-07-03 21:33:25 +00:00
|
|
|
|
|
|
|
- name: promote-container
|
|
|
|
image: scm.project42.io/elia/tricks:latest
|
|
|
|
environment:
|
|
|
|
REGISTRY_USERNAME:
|
|
|
|
from_secret: registry_username
|
|
|
|
REGISTRY_PASSWORD:
|
|
|
|
from_secret: registry_password
|
|
|
|
commands:
|
2023-07-05 21:53:11 +00:00
|
|
|
- oras tag --username "$REGISTRY_USERNAME" --password "$REGISTRY_PASSWORD" "scm.project42.io/elia/blog:${DRONE_COMMIT_SHA:0:8}" latest
|
2023-07-03 21:33:25 +00:00
|
|
|
depends_on:
|
|
|
|
- trivy-scan
|
2023-07-01 15:47:58 +00:00
|
|
|
when:
|
|
|
|
event:
|
|
|
|
- promote
|
|
|
|
target:
|
|
|
|
- production
|
2023-07-01 16:21:19 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
kind: pipeline
|
|
|
|
name: deploy-blog
|
|
|
|
|
|
|
|
clone:
|
|
|
|
depth: 1
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: syntax-check
|
|
|
|
image: plugins/ansible:latest
|
|
|
|
settings:
|
|
|
|
playbook: ansible/site.yml
|
|
|
|
inventory: ansible/inventory/hcloud.yml
|
|
|
|
requirements: ansible/requirements.txt
|
|
|
|
tags: blog
|
|
|
|
check: true
|
|
|
|
diff: true
|
|
|
|
syntax_check: true
|
|
|
|
extra_vars: "blog_container_tag=${DRONE_COMMIT_SHA:0:8}"
|
|
|
|
environment:
|
|
|
|
HCLOUD_TOKEN:
|
|
|
|
from_secret: hcloud_token
|
|
|
|
|
|
|
|
- name: dry-run
|
|
|
|
image: plugins/ansible:latest
|
|
|
|
settings:
|
|
|
|
playbook: ansible/site.yml
|
|
|
|
inventory: ansible/inventory/hcloud.yml
|
|
|
|
requirements: ansible/requirements.txt
|
|
|
|
tags: blog
|
|
|
|
check: true
|
|
|
|
diff: true
|
|
|
|
syntax_check: false
|
2023-07-01 17:08:30 +00:00
|
|
|
extra_vars: "blog_container_tag=${DRONE_COMMIT_SHA:0:8},check_mode=true"
|
2023-07-01 16:29:55 +00:00
|
|
|
private_key:
|
|
|
|
from_secret: ansible_private_key
|
|
|
|
user:
|
|
|
|
from_secret: ansible_user
|
2023-07-01 16:21:19 +00:00
|
|
|
environment:
|
|
|
|
HCLOUD_TOKEN:
|
|
|
|
from_secret: hcloud_token
|
|
|
|
|
|
|
|
- name: deploy
|
|
|
|
image: plugins/ansible:latest
|
|
|
|
settings:
|
|
|
|
playbook: ansible/site.yml
|
|
|
|
inventory: ansible/inventory/hcloud.yml
|
|
|
|
requirements: ansible/requirements.txt
|
|
|
|
tags: blog
|
|
|
|
check: false
|
|
|
|
diff: true
|
|
|
|
syntax_check: false
|
|
|
|
extra_vars: "blog_container_tag=${DRONE_COMMIT_SHA:0:8}"
|
2023-07-01 16:29:55 +00:00
|
|
|
private_key:
|
|
|
|
from_secret: ansible_private_key
|
|
|
|
user:
|
|
|
|
from_secret: ansible_user
|
2023-07-01 16:21:19 +00:00
|
|
|
environment:
|
|
|
|
HCLOUD_TOKEN:
|
|
|
|
from_secret: hcloud_token
|
|
|
|
when:
|
|
|
|
event:
|
|
|
|
- promote
|
|
|
|
target:
|
|
|
|
- production
|
|
|
|
|
|
|
|
depends_on:
|
|
|
|
- generate-blog
|