-
Notifications
You must be signed in to change notification settings - Fork 3
75 lines (60 loc) · 2.45 KB
/
sync_spectator.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Sync Changes On Spectator
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- ci/sync-spectator
jobs:
sync_changes:
runs-on: ubuntu-latest
steps:
- name: Checkout current repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get current branch name
id: get_branch
run: echo "::set-output name=branch::$(echo ${GITHUB_REF#refs/heads/})"
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Gather changed files
id: gather_files
run: |
git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > changed_files.txt
- name: Check if changed_files.txt is created
run: ls -l changed_files.txt
- name: Dump changed files
run: cat changed_files.txt
- name: Checkout target repository
uses: actions/checkout@v4
with:
repository: ${{ secrets.DEPLOY_TARGET_REPO_URL }}
token: ${{ secrets.DEPLOY_TARGET_REPO_ACCESS_TOKEN }}
ref: refs/heads/main # Change this to the default branch of target repository
- name: Check if changed_files.txt is created
run: ls
- name: Copy changed_files.txt to target repository
run: cp changed_files.txt $GITHUB_WORKSPACE/changed_files.txt
- name: Dump changed files
run: cat changed_files.txt
- name: Create new branch in target repository
run: |
git config --local user.email ${{ secrets.USER_EMAIL}}
git config --local user.name ${{ secrets.USER_NAME }}
git checkout -b ${{ steps.get_branch.outputs.branch }}
while IFS= read -r file; do
git add "$file"
done < changed_files.txt
git commit -m "Sync changes from PR #${{ github.event.number }}"
git push origin ${{ steps.get_branch.outputs.branch }}
- name: Create Pull Request in target repository
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.DEPLOY_TARGET_REPO_ACCESS_TOKEN }}
branch: ${{ steps.get_branch.outputs.branch }}
title: Sync changes from PR #${{ github.event.number }}
body: |
This Pull Request is automatically generated to sync changes from PR #${{ github.event.number }} in the source repository.