CI: Let's make CI workflows too.

This commit is contained in:
Skyler Mäntysaari 2023-03-02 02:50:17 +02:00
parent 00d7f2b0eb
commit d4ff839dd3
3 changed files with 130 additions and 25 deletions

View file

@ -0,0 +1,80 @@
name: "Charts: Release to GitHub pages"
on:
workflow_call:
inputs:
charts:
description: >
Json encoded list of Helm charts to release.
Defaults to releasing everything.
default: "[]"
required: false
type: string
secrets:
BOT_APP_ID:
required: true
BOT_APP_PRIVATE_KEY:
required: true
env:
HELM_VERSION: 3.10.2
jobs:
release-charts:
name: Release charts
#runs-on: ["self-hosted", "X64"]
runs-on: ubuntu-latest
steps:
- name: Workaround
run: export OPENSSL_CONF=/dev/null
- name: Checkout charts branch
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: "src"
fetch-depth: 0
- name: Checkout gh-pages branch
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN}}
path: "dest"
ref: "gh-pages"
fetch-depth: 0
- name: Install Kubernetes tools
uses: yokawasa/action-setup-kube-tools@v0.9.3
with:
setup-tools: |
helmv3
helm: "${{ env.HELM_VERSION }}"
- name: Package Helm Charts
shell: bash
env:
SRC_DIR: "src/charts"
DEST_DIR: "dest"
run: |
CHARTS=( $(yq --null-input e '${{ inputs.charts }}[]' ) )
for CHART in "${CHARTS[@]}" ; do
mapfile -t CHART_PATH_PARTS < <(echo "$CHART" | tr '/' '\n')
CHART_TYPE=${CHART_PATH_PARTS[0]}
helm dep up "${SRC_DIR}/${CHART}"
helm package "${SRC_DIR}/${CHART}" -u -d "${DEST_DIR}/${CHART_TYPE}"
done
- name: Update chart index
shell: bash
working-directory: dest
run: |
helm repo index . --url https://helm.samipsolutions.fi/
- name: Commit changes
shell: bash
working-directory: dest
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@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

50
.github/workflows/charts-release.yaml vendored Normal file
View file

@ -0,0 +1,50 @@
name: "Charts: Release"
concurrency: helm-release
on:
workflow_dispatch:
inputs:
charts:
description: >
Charts to release. Comma-separated string.
Defaults to releasing everything.
default: ""
required: false
push:
branches:
- main
paths:
- "charts/**"
env:
HELM_VERSION: 3.10.2
jobs:
prepare:
name: Prepare data required for release
runs-on: ubuntu-latest
outputs:
charts-to-release: ${{ steps.collect-charts.outputs.charts }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Collect charts to release
uses: bjw-s/helm-charts-actions/collect-charts@main
id: collect-charts
with:
repoConfigFile: ./.ci/repo-config.yaml
overrideCharts: "[${{ inputs.charts }}]"
release-github-pages:
name: Release Charts to GitHub pages
uses: ./.github/workflows/charts-release-ghpages.yaml
needs:
- prepare
with:
charts: "${{ needs.prepare.outputs.charts-to-release }}"
secrets: inherit

View file

@ -1,25 +0,0 @@
name: Release Charts
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.1.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"