Skip to content

Commit

Permalink
Automate Kyverno manifest updates
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <[email protected]>
  • Loading branch information
stefanprodan committed Dec 8, 2020
1 parent bb3b5e1 commit 37a52da
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
4 changes: 1 addition & 3 deletions .github/actions/tools/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@ KUSTOMIZE_VERSION="3.8.6"
KUBEVAL_VERSION="0.15.0"

mkdir -p $GITHUB_WORKSPACE/bin
cd $GITHUB_WORKSPACE/bin

curl -sL https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -o yq

cp ./yq $GITHUB_WORKSPACE/bin
chmod +x $GITHUB_WORKSPACE/bin/yq

kustomize_url=https://github.com/kubernetes-sigs/kustomize/releases/download && \
curl -sL ${kustomize_url}/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_amd64.tar.gz | \
tar xz

cp ./kustomize $GITHUB_WORKSPACE/bin
chmod +x $GITHUB_WORKSPACE/bin/kustomize

curl -sL https://github.com/instrumenta/kubeval/releases/download/${KUBEVAL_VERSION}/kubeval-linux-amd64.tar.gz | \
tar xz

cp ./kubeval $GITHUB_WORKSPACE/bin
chmod +x $GITHUB_WORKSPACE/bin/kubeval

echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: update

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"

jobs:
kyverno:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup tools
uses: ./.github/actions/tools
- name: Fetch latest version
id: version
run: |
REPO="https://github.com/kyverno/kyverno.git"
VERSION=$(cd /tmp && git ls-remote --tags --refs --sort='version:refname' ${REPO} | \
sed 's/.*\///' | \
awk '{ if ($1 ~ /-/) print; else print $0"_" ; }' | \
sort -rV | \
sed 's/_$//' | \
head -n1)
echo ::set-output name=NUMBER::${VERSION}
- name: Patch version
run: |
URL="https://raw.githubusercontent.com/kyverno/kyverno/${{ steps.version.outputs.NUMBER }}/definitions/release/install.yaml"
yq w -i ./infrastructure/kyverno/kustomization.yaml resources[0] ${URL}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
branch: update-kyverno
committer: GitHub <[email protected]>
author: fluxcdbot <[email protected]>
commit-message: Update kyverno to ${{ steps.version.outputs.NUMBER }}
title: Update kyverno to ${{ steps.version.outputs.NUMBER }}
body: |
kyverno ${{ steps.version.outputs.NUMBER }}

0 comments on commit 37a52da

Please sign in to comment.