feat: AI playbook actions (#365) #244
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Beta Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
changes: | |
runs-on: ubuntu-latest | |
# Required permissions | |
permissions: | |
pull-requests: read | |
outputs: | |
# Expose matched filters as job 'packages' output variable | |
charts: ${{ steps.filter.outputs.changes }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
argocd: charts/argocd/** | |
aws: charts/aws/** | |
azure: charts/azure/** | |
kubernetes: charts/kubernetes/** | |
mission-control: charts/mission-control/** | |
flux: charts/flux/** | |
mongo-atlas: charts/mongo-atlas/** | |
postgres: charts/postgres/** | |
prometheus: charts/prometheus/** | |
playbooks-kubernetes: charts/playbooks-kubernetes/** | |
playbooks-ai: charts/playbooks-ai/** | |
playbooks-flux: charts/playbooks-flux/** | |
helm: charts/helm/** | |
# Job to build and test each of modified packages | |
build: | |
needs: changes | |
strategy: | |
matrix: | |
# Parse JSON array containing names of all filters matching any of changed files | |
# e.g. ['package1', 'package2'] if both package folders contains changes | |
chart: ${{ fromJSON(needs.changes.outputs.charts) }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: "${{ secrets.FLANKBOT }}" | |
- name: Set up Helm | |
uses: azure/setup-helm@v1 | |
with: | |
version: v3.12.0 | |
- name: Package Helm chart | |
run: | | |
cd charts/${{ matrix.chart }} | |
CURRENT_CHART_VERSION=$(cat Chart.yaml | yq '.version') | |
# Regex to match SemVer pattern with optional beta version | |
# This matches versions like `1.2.3`, `1.2.3-beta.1`, etc. | |
SEMVER_REGEX="^([0-9]+)\.([0-9]+)\.([0-9]+)(-beta\.([0-9]+))?$" | |
# Check if version matches the SemVer pattern | |
if [[ $CURRENT_CHART_VERSION =~ $SEMVER_REGEX ]]; then | |
MAJOR="${BASH_REMATCH[1]}" | |
MINOR="${BASH_REMATCH[2]}" | |
PATCH="${BASH_REMATCH[3]}" | |
BETA="${BASH_REMATCH[5]}" | |
if [[ -n "$BETA" ]]; then | |
# If there's a beta version, increment it | |
NEW_BETA=$((BETA + 1)) | |
NEW_CHART_VERSION="${MAJOR}.${MINOR}.${PATCH}-beta.${NEW_BETA}" | |
else | |
# If no beta version, bump the PATCH and start with beta.1 | |
NEW_PATCH=$((PATCH + 1)) | |
NEW_CHART_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}-beta.1" | |
fi | |
else | |
echo "Invalid semantic version format." | |
exit 1 | |
fi | |
echo NEW_CHART_VERSION=$NEW_CHART_VERSION >> $GITHUB_ENV | |
yq -i e ".version |= \"$NEW_CHART_VERSION\"" Chart.yaml | |
helm package -d ../.. . | |
git config --global user.name 'flankbot' | |
git config --global user.email '[email protected]' | |
git add Chart.yaml | |
git pull --rebase origin main --autostash | |
git commit -m "[skip ci] bump chart ${{matrix.chart}} to $NEW_CHART_VERSION" | |
git push | |
- name: Clone charts repo | |
uses: actions/checkout@v3 | |
with: | |
repository: "${{ github.repository_owner }}/charts" | |
path: chart-index | |
token: "${{ secrets.FLANKBOT }}" | |
- name: Update chart repo | |
run: | | |
cd chart-index | |
cp ../mission-control-*.tgz ./ | |
helm repo index --merge index.yaml . | |
- name: Push changes to chart repo | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "Release ${{ env.NEW_CHART_VERSION }} of mission-control-${{ matrix.chart }}" | |
branch: gh-pages | |
repository: ./chart-index |