Skip to content

Commit

Permalink
add ci worklofw to check clusterpedia crd whether been update
Browse files Browse the repository at this point in the history
Signed-off-by: calvin <[email protected]>
  • Loading branch information
calvin committed Nov 1, 2022
1 parent b416793 commit 7a48e1b
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/lint-crd-sync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# validate any chart changes under charts directory
name: Clusterpedia crd sync

env:
CLUSTERPEDIA_REPO: https://github.com/clusterpedia-io/clusterpedia.git
TMP_DIR: /tmp/clusterpedia
CLUSTERPEDIA_CRD_DIR: deploy/crds
CLSUTERPEDIA_HELM_CRD_DIR: charts/clusterpedia/_crds
CHART_YAML_PATH: charts/clusterpedia/Chart.yaml
IGNORE_MATCHING_LINES: "helm.sh/resource-policy: keep"

on:
push:
pull_request:

jobs:
crd-sync-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Lookup clusterpedia version
run: |
APP_VERSION=$(yq '.appVersion' < ${{ env.CHART_YAML_PATH }})
echo "APP_VERSION=${APP_VERSION,,}" >> ${GITHUB_ENV}
- name: Pull clusterpedia code
run: |
echo ${{ env.APP_VERSION }}
echo "pull clusterpedia from https://github.com/clusterpedia-io/clusterpedia.git"
git clone --single-branch --depth 1 --branch ${{ env.APP_VERSION }} ${{ env.CLUSTERPEDIA_REPO }} ${{ env.TMP_DIR }}
- name: check whether crd is sync
run: |
ret=0
diff -Naupr -I ${{ env.IGNORE_MATCHING_LINES }} ${{ env.CLSUTERPEDIA_HELM_CRD_DIR }} ${{ env.TMP_DIR }}/${{ env.CLUSTERPEDIA_CRD_DIR }} || ret=$?
if [[ $ret -eq 1 ]]
then
echo "clusterpedia crd has been change, please update synchronouly this repo crd resource."
exit 1
fi
- name: cleanup
run: |
echo "remove clusterpedia code"
rm ${{ env.TMP_DIR }} -rf

0 comments on commit 7a48e1b

Please sign in to comment.