-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (57 loc) · 2.22 KB
/
auto-sync-manifest.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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 }}