Skip to content

Auto Sync Manifest v0.29.0-alpha.4 #47

Auto Sync Manifest v0.29.0-alpha.4

Auto Sync Manifest v0.29.0-alpha.4 #47

name: Auto Sync Manifest
on:
workflow_dispatch:
inputs:
VERSION:
description: 'The version of release'
type: string
required: true
default: ''
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run-name: Auto Sync Manifest ${{ inputs.VERSION }}
jobs:
sync-manifest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: get version
id: get-version
run: |
RELEASE_VERSION="${{ inputs.VERSION }}"
if [[ "${RELEASE_VERSION}" != "v"* ]]; then
RELEASE_VERSION="v${RELEASE_VERSION}"
fi
echo "release-version=${RELEASE_VERSION}" >> $GITHUB_OUTPUT
- name: Checkout apecloud Code
uses: actions/checkout@v4
with:
repository: apecloud/apecloud
path: apecloud
token: ${{ env.GITHUB_TOKEN }}
ref: ${{ steps.get-version.outputs.release-version }}
- name: check manifest
id: check-manifest
run: |
COMMIT_SHA="$(git rev-parse HEAD)"
release_version="${{ steps.get-version.outputs.release-version }}"
MANIFEST_DIR="manifests/${release_version}"
mkdir -p ${MANIFEST_DIR}
cp -r ${{ github.workspace }}/apecloud/manifests/deploy-manifests.yaml ${MANIFEST_DIR}/manifests.yaml
cp -r ${{ github.workspace }}/apecloud/manifests/deploy-values.yaml ${MANIFEST_DIR}/values.yaml
git add ${MANIFEST_DIR}/*
FILE_CHANGES=`git diff --name-only ${COMMIT_SHA}`
if [[ ! -z "$FILE_CHANGES" ]]; then
echo "FILE_CHANGES:"$FILE_CHANGES
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git commit -a -m "chore: auto sync manifest ${release_version}"
fi
echo file_changes=$FILE_CHANGES >> $GITHUB_OUTPUT
echo changes_dir=$MANIFEST_DIR >> $GITHUB_OUTPUT
- name: Push manifest changes
uses: ad-m/github-push-action@master
if: ${{ steps.check-manifest.outputs.file_changes }}
with:
directory: ./${{ steps.check-manifest.outputs.changes_dir }}
github_token: ${{ env.GITHUB_TOKEN }}