-
Notifications
You must be signed in to change notification settings - Fork 568
57 lines (51 loc) · 1.78 KB
/
sync-feature-code.yaml
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
name: Sync Feature Branch to Main
on:
schedule:
- cron: '0 0 * * *' # Runs daily at midnight
workflow_dispatch: # Manual trigger
jobs:
sync-feature:
runs-on: ubuntu-latest
steps:
- name: Check if PR has merged
id: check_pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ $(gh pr ls -H sync-feature-to-main -B master -R kubesphere/kubekey) == "" ]]; then
echo "pr_merged=true" >> $GITHUB_OUTPUT
else
echo "pr_merged=false" >> $GITHUB_OUTPUT
fi
- name: Checkout master branch
if: ${{ steps.check_pr.outputs.pr_merged == 'true' }}
uses: actions/checkout@v3
with:
ref: master
- name: Checkout feature branch
if: ${{ steps.check_pr.outputs.pr_merged == 'true' }}
uses: actions/checkout@v3
with:
ref: feature-gitops
path: feature-branch
- name: Sync feature branch to master/feature directory
if: ${{ steps.check_pr.outputs.pr_merged == 'true' }}
run: |
rm -rf feature && mkdir -p feature
rm -rf feature-branch/vendor
cp -r feature-branch/* feature/
rm -rf feature-branch
- name: Push changes and create PR
if: ${{ steps.check_pr.outputs.pr_merged == 'true' }}
uses: peter-evans/create-pull-request@v7
with:
commit-message: 'Sync feature branch to master/feature directory'
delete-branch: true
branch: sync-feature-to-main
sign-commits: true
title: '[ci-bot] Sync feature branch to master/feature directory'
body: |
This PR syncs the feature branch to the master/feature directory.
```release-note
none
```