mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-31 17:28:13 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8ed5721cd6 | |||
| 3daecd3465 | |||
| b14bcd15c2 | |||
| 9411e6c2ee | |||
| fbe76255d5 | |||
| 6f98c392b5 | |||
| b5006b7cce | |||
| b41e0f49bf |
@@ -0,0 +1,38 @@
|
||||
steps:
|
||||
helm:
|
||||
when:
|
||||
- event: pull_request
|
||||
branch: main-v2
|
||||
- event: push
|
||||
branch: main-v2
|
||||
image: alpine/helm:4.1.1
|
||||
environment:
|
||||
chart_dir: script/helm/garage
|
||||
chart_name: garage
|
||||
registry_host: codeberg.org
|
||||
registry_user: ${CI_REPO_OWNER}
|
||||
registry_path: ${CI_REPO}
|
||||
|
||||
# To create registry_password:
|
||||
# 1. Go to https://codeberg.org/user/settings/applications.
|
||||
# 2. Create a token with these settings:
|
||||
# - Token name: https://git.deuxfleurs.fr/3uzbcqje/garage/src/branch/main-v2/.woodpecker/helm.yaml
|
||||
# - Set package permission to "Read and write".
|
||||
# 3. Click "Generate token".
|
||||
# 4. Copy the token.
|
||||
# 5. Log into https://ci.codeberg.org.
|
||||
# 6. Find your repo, and add a secret with these settings:
|
||||
# - Name: registry_password
|
||||
# - Value: <the token you copied earlier>
|
||||
# 7. Click "Add secret".
|
||||
|
||||
registry_password:
|
||||
from_secret: registry_password
|
||||
|
||||
commands:
|
||||
- |
|
||||
if [[ "${CI_PIPELINE_EVENT}" == "push" && "${CI_COMMIT_BRANCH}" == "${CI_REPO_DEFAULT_BRANCH}" ]]; then
|
||||
./pipeline.sh push
|
||||
else
|
||||
./pipeline.sh
|
||||
fi
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
|
||||
# Not using "-x" because we aren't debugging.
|
||||
set -Eeuo pipefail
|
||||
|
||||
# We get unbound var err if we don't set arg
|
||||
arg="${1:-}"
|
||||
|
||||
echo "${registry_password}" | helm registry login -u "${registry_user}" --password-stdin "${registry_host}"
|
||||
helm lint "${chart_dir}"
|
||||
chart_version=$(grep '^version: ' "${chart_dir}/Chart.yaml" | cut -d' ' -f 2)
|
||||
helm package "${chart_dir}"
|
||||
|
||||
# If chart already exists in the chart repository, don't push.
|
||||
if helm pull "oci://${registry_host}/${registry_path}/${chart_name}" --version "${chart_version}" &> /dev/null; then
|
||||
echo -e "\e[31mWARNING: Chart ${chart_name} version ${chart_version} already exists in the repository.\nThis means that the chart's code has not changed, or you forgot to update the version in Chart.yaml.\e[0m"
|
||||
else
|
||||
if [[ $arg == 'push' ]]; then
|
||||
helm push "${chart_name}-${chart_version}.tgz" "oci://${registry_host}/${registry_path}"
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user