File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments