-
Notifications
You must be signed in to change notification settings - Fork 2
57 lines (47 loc) · 1.76 KB
/
commit-main.yaml
File metadata and controls
57 lines (47 loc) · 1.76 KB
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: Commit to Main Repository
on:
push:
tags:
- 'v*.*.*'
jobs:
commit-to-main:
name: Commit to Main Repository
runs-on: ubuntu-latest
steps:
- name: Checkout source repository (current repository)
uses: actions/checkout@v3
with:
path: source-repo
- name: Get tag version
id: version
run: |
cd source-repo
VERSION="${GITHUB_REF#refs/tags/}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Checkout target repository (costrict-enterprise)
uses: actions/checkout@v3
with:
repository: zgsm-ai/costrict-enterprise
token: ${{ secrets.PAT_TOKEN }}
path: target-repo
- name: Determine target directory
id: target_dir
run: |
cd target-repo
if [ -n "${{ secrets.MAIN_DIRECTORY }}" ]; then
TARGET_DIR="${{ secrets.MAIN_DIRECTORY }}"
else
TARGET_DIR="services/${{ github.event.repository.name }}"
fi
echo "target_dir=$TARGET_DIR" >> $GITHUB_OUTPUT
- name: Copy source repository content to target directory
run: |
rsync -av --exclude='.git' source-repo/ "target-repo/${{ steps.target_dir.outputs.target_dir }}/"
- name: Commit and push changes
run: |
cd target-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A "${{ steps.target_dir.outputs.target_dir }}"
git diff --staged --quiet || git commit -m "chore: update ${{ github.event.repository.name }} to ${{ steps.version.outputs.version }}"
git push origin main