Skip to content

Commit 4b319cb

Browse files
authored
Add files via upload
1 parent 15e91b3 commit 4b319cb

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/commit-main.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Commit to Main Repository
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
commit-to-main:
10+
name: Commit to Main Repository
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout source repository (current repository)
14+
uses: actions/checkout@v3
15+
with:
16+
path: source-repo
17+
18+
- name: Get tag version
19+
id: version
20+
run: |
21+
cd source-repo
22+
VERSION="${GITHUB_REF#refs/tags/}"
23+
echo "version=$VERSION" >> $GITHUB_OUTPUT
24+
25+
- name: Checkout target repository (costrict-backend)
26+
uses: actions/checkout@v3
27+
with:
28+
repository: zgsm-ai/costrict-backend
29+
token: ${{ secrets.PAT_TOKEN }}
30+
path: target-repo
31+
32+
- name: Determine target directory
33+
id: target_dir
34+
run: |
35+
cd target-repo
36+
if [ -n "${{ secrets.MAIN_DIRECTORY }}" ]; then
37+
TARGET_DIR="${{ secrets.MAIN_DIRECTORY }}"
38+
else
39+
TARGET_DIR="services/${{ github.event.repository.name }}"
40+
fi
41+
echo "target_dir=$TARGET_DIR" >> $GITHUB_OUTPUT
42+
43+
- name: Copy source repository content to target directory
44+
run: |
45+
rsync -av --exclude='.git' source-repo/ "target-repo/${{ steps.target_dir.outputs.target_dir }}/"
46+
47+
- name: Commit and push changes
48+
run: |
49+
cd target-repo
50+
git config user.name "github-actions[bot]"
51+
git config user.email "github-actions[bot]@users.noreply.github.com"
52+
git add -A "${{ steps.target_dir.outputs.target_dir }}"
53+
git diff --staged --quiet || git commit -m "chore: update ${{ github.event.repository.name }} to ${{ steps.version.outputs.version }}"
54+
git push origin main
55+
56+

0 commit comments

Comments
 (0)