forked from swagger-api/swagger-ui
-
Notifications
You must be signed in to change notification settings - Fork 3
79 lines (64 loc) · 3.02 KB
/
sync-to-backend-repo.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Sync Files to Backend Repository
on:
pull_request:
branches:
- master
types:
- closed # PR이 master에 머지될 때만
jobs:
sync_files:
runs-on: ubuntu-latest
steps:
- name: Checkout Frontend Repository
uses: actions/checkout@v3
- name: Install dependencies and build
run: |
npm install # 또는 yarn install
npm run build # 또는 yarn build
# Configure Git with PR Author
- name: Configure Git with PR Author
run: |
if [[ "${{ github.event.pull_request.merged }}" == 'true' ]]; then
git config --global user.name "${{ github.event.pull_request.user.login }}"
git config --global user.email "${{ github.event.pull_request.user.login }}@users.noreply.github.com"
fi
# Commit with PR Author info
- name: Amend Commit with Author Info
run: |
if [[ "${{ github.event.pull_request.merged }}" == 'true' ]]; then
git commit --amend --no-edit --author="${{ github.event.pull_request.user.login }} <${{ github.event.pull_request.user.login }}@users.noreply.github.com>"
git push origin main --force
echo "Git user.name: $(git config user.name)"
fi
# Commit with PR Title as Message
- name: Commit with PR Title as Message
run: |
if [[ "${{ github.event.pull_request.merged }}" == 'true' ]]; then
git commit --amend --no-edit --author="${{ github.event.pull_request.user.login }} <${{ github.event.pull_request.user.login }}@users.noreply.github.com>"
git commit -m "${{ github.event.pull_request.title }}"
git push origin main --force
fi
- name: Sync Files to Backend Repository
run: |
if [[ "${{ github.event.pull_request.merged }}" == 'true' ]]; then
git clone https://westofsky:${{secrets.PAT}}@github.com/Swaggy-Swagger/swagger-custom-java.git
cd swagger-custom-java
# Git 사용자 정보 설정
git config user.name "${{ github.event.pull_request.user.login }}"
git config user.email "${{ github.event.pull_request.user.login }}@users.noreply.github.com"
# A 레포지토리에서 B 레포지토리로 파일 복사
cp ../dist/swagger-ui.css src/main/resources/META-INF/resources/webjars/swagger-ui/swagger-ui.css
cp ../dist/swagger-ui-bundle.js src/main/resources/META-INF/resources/webjars/swagger-ui/swagger-ui-bundle.js
cp ../dist/swagger-ui-standalone-preset.js src/main/resources/META-INF/resources/webjars/swagger-ui/swagger-ui-standalone-preset.js
git add .
git commit -m "${{ github.event.pull_request.title }}"
# Ensure the style/ui branch exists
git branch -M style/ui
git fetch origin style/ui
# Merge changes and override conflicts with ours
git merge -X ours origin/style/ui
# Push the changes to the style/ui branch
git push -u origin style/ui
fi
env:
GITHUB_TOKEN: ${{ secrets.PAT }}