mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 08:57:04 +02:00
ci: 🧠
This commit is contained in:
parent
d2443fedc0
commit
f5d7891eff
2 changed files with 59 additions and 50 deletions
16
.github/workflows/charts-lint.yaml
vendored
16
.github/workflows/charts-lint.yaml
vendored
|
@ -6,9 +6,6 @@ on:
|
||||||
checkoutCommit:
|
checkoutCommit:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
chartChangesDetected:
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
chartChanges:
|
chartChanges:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
@ -37,19 +34,6 @@ jobs:
|
||||||
- name: Set up chart-testing
|
- name: Set up chart-testing
|
||||||
uses: helm/chart-testing-action@v2.2.1
|
uses: helm/chart-testing-action@v2.2.1
|
||||||
|
|
||||||
# - name: Collect changes
|
|
||||||
# id: list-changed
|
|
||||||
# if: inputs.chartChangesDetected == 'true'
|
|
||||||
# run: |
|
|
||||||
# EXCLUDED=$(yq eval -o=json '.excluded-charts // []' .ci/ct/ct-lint.yaml)
|
|
||||||
# CHARTS=$(ct list-changed --config .ci/ct/ct-lint.yaml)
|
|
||||||
# CHARTS_JSON=$(echo "${CHARTS}" | jq -R -s -c 'split("\n")[:-1]')
|
|
||||||
# OUTPUT_JSON=$(echo "{\"excluded\": ${EXCLUDED}, \"all\": ${CHARTS_JSON}}" | jq -c '.all-.excluded')
|
|
||||||
# echo ::set-output name=charts::${OUTPUT_JSON}
|
|
||||||
# if [[ $(echo ${OUTPUT_JSON} | jq -c '. | length') -gt 0 ]]; then
|
|
||||||
# echo "::set-output name=detected::true"
|
|
||||||
# fi
|
|
||||||
|
|
||||||
- name: Run chart-testing (lint)
|
- name: Run chart-testing (lint)
|
||||||
id: lint
|
id: lint
|
||||||
if: inputs.chartChanges != ''
|
if: inputs.chartChanges != ''
|
||||||
|
|
93
.github/workflows/charts-release.yaml
vendored
93
.github/workflows/charts-release.yaml
vendored
|
@ -11,8 +11,53 @@ on:
|
||||||
- "charts/**"
|
- "charts/**"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
collect-changes:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
changesDetected: ${{ steps.filter.outputs.chartsAddedOrModified }}
|
||||||
|
addedOrModifiedCharts: ${{ steps.filter-charts.outputs.addedOrModifiedCharts }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
token: ${{ steps.get-app-token.outputs.token }}
|
||||||
|
|
||||||
|
- name: Collect changes
|
||||||
|
uses: dorny/paths-filter@v2
|
||||||
|
id: filter
|
||||||
|
with:
|
||||||
|
list-files: shell
|
||||||
|
filters: |
|
||||||
|
chartsAddedOrModified:
|
||||||
|
- added|modified: 'charts/*/**'
|
||||||
|
|
||||||
|
- name: Collect changed charts
|
||||||
|
if: |
|
||||||
|
steps.filter.outputs.chartsAddedOrModified == 'true'
|
||||||
|
id: filter-charts
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
CHARTS=()
|
||||||
|
PATHS=(${{ steps.filter.outputs.chartsAddedOrModified_files }})
|
||||||
|
# Get only the chart paths
|
||||||
|
for CHARTPATH in "${PATHS[@]}"
|
||||||
|
do
|
||||||
|
IFS='/' read -r -a path_parts <<< "${CHARTPATH}"
|
||||||
|
CHARTS+=("${path_parts[1]}/${path_parts[2]}")
|
||||||
|
done
|
||||||
|
# Remove duplicates
|
||||||
|
CHARTS=( `printf "%s\n" "${CHARTS[@]}" | sort -u` )
|
||||||
|
# Set output to changed charts
|
||||||
|
printf "::set-output name=addedOrModifiedCharts::%s\n" "${CHARTS[*]}"
|
||||||
|
|
||||||
release-charts:
|
release-charts:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
needs:
|
||||||
|
- collect-changes
|
||||||
|
if:
|
||||||
|
needs.collect-changes.outputs.changesDetected == 'true'
|
||||||
steps:
|
steps:
|
||||||
- name: Get k8s-at-home token
|
- name: Get k8s-at-home token
|
||||||
id: get-app-token
|
id: get-app-token
|
||||||
|
@ -44,9 +89,8 @@ jobs:
|
||||||
env:
|
env:
|
||||||
SRC_DIR: "src/charts"
|
SRC_DIR: "src/charts"
|
||||||
DEST_DIR: "dest"
|
DEST_DIR: "dest"
|
||||||
|
CHARTS: "${{ needs.collect-changes.outputs.addedOrModifiedCharts }}"
|
||||||
run: |
|
run: |
|
||||||
CHARTS=$(find "$SRC_DIR" -type f -name 'Chart.yaml' | sed -r 's|/[^/]+$||' | sort | uniq)
|
|
||||||
|
|
||||||
for CHART in $CHARTS ; do
|
for CHART in $CHARTS ; do
|
||||||
mapfile -t CHART_PATH_PARTS < <(echo "$CHART" | tr '/' '\n')
|
mapfile -t CHART_PATH_PARTS < <(echo "$CHART" | tr '/' '\n')
|
||||||
CHART_TYPE=${CHART_PATH_PARTS[2]}
|
CHART_TYPE=${CHART_PATH_PARTS[2]}
|
||||||
|
@ -55,38 +99,19 @@ jobs:
|
||||||
helm package "$CHART" -u -d "$DEST_DIR/$CHART_TYPE"
|
helm package "$CHART" -u -d "$DEST_DIR/$CHART_TYPE"
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Create new index
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Push Charts to GHCR
|
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
working-directory: dest
|
||||||
DEST_DIR: "dest"
|
|
||||||
run: |
|
run: |
|
||||||
for pkg in $DEST_DIR/**/*; do
|
helm repo index . --url https://bjw-s.github.io/helm-charts/
|
||||||
if [ -z "${pkg:-}" ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
helm push "${pkg}" oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/helm-charts
|
|
||||||
done
|
|
||||||
|
|
||||||
# - name: Create new index
|
- name: Push changes
|
||||||
# shell: bash
|
shell: bash
|
||||||
# working-directory: dest
|
working-directory: dest
|
||||||
# run: |
|
run: |
|
||||||
# helm repo index . --url https://bjw-s.github.io/helm-charts/
|
git config user.name "bjw-s-bot[bot]"
|
||||||
|
git config user.email "bjw-s-bot <87358111+bjw-s-bot[bot]@users.noreply.github.com>"
|
||||||
# - name: Push changes
|
git add $(git ls-files -o --exclude-standard)
|
||||||
# shell: bash
|
git add index.yaml
|
||||||
# working-directory: dest
|
git commit -m "Updated from ref: $GITHUB_SHA"
|
||||||
# run: |
|
git push
|
||||||
# git config user.name "bjw-s-bot[bot]"
|
|
||||||
# git config user.email "bjw-s-bot <87358111+bjw-s-bot[bot]@users.noreply.github.com>"
|
|
||||||
# git add $(git ls-files -o --exclude-standard)
|
|
||||||
# git add index.yaml
|
|
||||||
# git commit -m "Updated from ref: $GITHUB_SHA"
|
|
||||||
# git push
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue