This commit is contained in:
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 2022-07-27 11:15:03 +02:00
parent d2443fedc0
commit f5d7891eff
No known key found for this signature in database
GPG key ID: BC5E2BD907F9A8EC
2 changed files with 59 additions and 50 deletions

View file

@ -6,9 +6,6 @@ on:
checkoutCommit:
required: true
type: string
chartChangesDetected:
required: true
type: string
chartChanges:
required: true
type: string
@ -37,19 +34,6 @@ jobs:
- name: Set up chart-testing
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)
id: lint
if: inputs.chartChanges != ''

View file

@ -11,8 +11,53 @@ on:
- "charts/**"
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:
runs-on: ubuntu-22.04
needs:
- collect-changes
if:
needs.collect-changes.outputs.changesDetected == 'true'
steps:
- name: Get k8s-at-home token
id: get-app-token
@ -44,9 +89,8 @@ jobs:
env:
SRC_DIR: "src/charts"
DEST_DIR: "dest"
CHARTS: "${{ needs.collect-changes.outputs.addedOrModifiedCharts }}"
run: |
CHARTS=$(find "$SRC_DIR" -type f -name 'Chart.yaml' | sed -r 's|/[^/]+$||' | sort | uniq)
for CHART in $CHARTS ; do
mapfile -t CHART_PATH_PARTS < <(echo "$CHART" | tr '/' '\n')
CHART_TYPE=${CHART_PATH_PARTS[2]}
@ -55,38 +99,19 @@ jobs:
helm package "$CHART" -u -d "$DEST_DIR/$CHART_TYPE"
done
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Charts to GHCR
- name: Create new index
shell: bash
env:
DEST_DIR: "dest"
working-directory: dest
run: |
for pkg in $DEST_DIR/**/*; do
if [ -z "${pkg:-}" ]; then
break
fi
helm push "${pkg}" oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/helm-charts
done
helm repo index . --url https://bjw-s.github.io/helm-charts/
# - name: Create new index
# shell: bash
# working-directory: dest
# run: |
# helm repo index . --url https://bjw-s.github.io/helm-charts/
# - name: Push changes
# shell: bash
# working-directory: dest
# run: |
# 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
- name: Push changes
shell: bash
working-directory: dest
run: |
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