Skip to content

Commit 23a8efc

Browse files
committed
yy
1 parent 2635b28 commit 23a8efc

1 file changed

Lines changed: 39 additions & 27 deletions

File tree

.github/workflows/create-fuse-ko-pr.yml

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,43 @@
1-
# This is a basic workflow to help you get started with Actions
1+
# Copy fuse related codes from branches and create PR for fuse-kernel-modules.
22

33
name: Sync to fuse-kernel-modules
44

5-
# Controls when the workflow will run
65
on:
7-
# Triggers the workflow on push or pull request events but only for the "main" branch
6+
# Triggers the workflow on push or pull request events for target branches.
87
push:
98
branches: [ "*" ]
109
pull_request:
1110
branches: [ "*" ]
1211

13-
# Allows you to run this workflow manually from the Actions tab
12+
# Allows you to run this workflow manually from the Actions tab.
1413
workflow_dispatch:
1514

16-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1715
jobs:
18-
# This workflow contains a single job called "build"
1916
sync:
20-
# The type of runner that the job will run on
2117
runs-on: ubuntu-latest
22-
23-
# Steps represent a sequence of tasks that will be executed as part of the job
2418
steps:
25-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
19+
# Checks-out to a different directory to avoid following checkout remove it.
2620
- uses: actions/checkout@v4
2721
with:
2822
path: linux
2923

30-
- uses: actions/checkout@v4
24+
- name: Try to checkout sync-${{ github.ref_name }} if it exists
25+
uses: actions/checkout@v4
26+
id: try-checkout
27+
continue-on-error: true
28+
with:
29+
repository: openunix/fuse-kernel-modules
30+
ref: sync-${{ github.ref_name }}
31+
fetch-depth: 0
32+
path: fuse-kernel-modules
33+
token: ${{ secrets.OPENUNIXPAT }}
34+
35+
- name: Fallback to checkout main
36+
if: steps.try-checkout.outcome == 'failure'
37+
uses: actions/checkout@v4
3138
with:
3239
repository: openunix/fuse-kernel-modules
33-
ref: "sync-${{ github.ref_name }}"
40+
ref: main
3441
fetch-depth: 0
3542
path: fuse-kernel-modules
3643
token: ${{ secrets.OPENUNIXPAT }}
@@ -41,37 +48,42 @@ jobs:
4148
${{ secrets.GPG_PRIVATE_KEY }}
4249
EOF
4350
44-
# Runs a single command using the runners shell
45-
- name: Generate codes for fuse-kernel-modules
51+
- name: Initialize git
4652
run: |
47-
pushd fuse-kernel-modules
48-
./copy-from-linux-branch $GITHUB_WORKSPACE/linux ${{ github.ref_name }}
4953
git config --global user.name "Feng Shuo"
5054
git config --global user.email "steve.shuo.feng@gmail.com"
51-
git config --global user.signingkey F96A409277704327
55+
git config --global user.signingkey F96A409277704327
56+
57+
- name: Create tracking branch based on main
58+
if: steps.try-checkout.outcome == 'failure'
59+
run: |
60+
pushd fuse-kernel-modules
61+
git checkount -b sync-${{ github.ref_name }}
62+
63+
- name: Generate PR for fuse-kernel-modules
64+
run: |
65+
pushd fuse-kernel-modules
66+
./copy-from-linux-branch $GITHUB_WORKSPACE/linux ${{ github.ref_name }}
5267
git add src/${{ github.ref_name }}
5368
echo -e "Auto sync with openunix/linux branch ${{ github.ref_name }} \n" > ../commit.msg
5469
echo -e "Auto sync with openunix/linux branch ${{ github.ref_name }} commit" >> ../commit.msg
5570
echo -e "${{ github.sha }}" >> ../commit.msg
56-
cat ../commit.msg
57-
git commit -S -F ../commit.msg 2> ../commit.log ||:
71+
git commit -S -F ../commit.msg 2> ../commit.log; ERR=$?
5872
if [ -s ../commit.log ]; then
59-
echo "Error detcted:"
73+
echo "Error detcted in commit:"
6074
cat ../commit.log
61-
else
75+
elsif [ $ERR -eq 0 ]; then
6276
echo "Done. Push the code to remote:"
63-
git push 2> ../push.log ||:
77+
git push origin sync-${{ github.ref_name }} 2> ../push.log ||:
78+
else
79+
echo "No changes to existed codes. Still try with PR."
6480
fi
6581
if [ -s ../push.log ]; then
82+
echo "Error detected in push:"
6683
cat ../push.log
6784
fi
6885
gh pr create --base main --fill
6986
popd
7087
env:
7188
GH_TOKEN: ${{ secrets.OPENUNIXPAT }}
7289

73-
# Runs a set of commands using the runners shell
74-
- name: Run a multi-line script
75-
run: |
76-
echo ${{ github.ref_name }}
77-
find $GITHUB_WORKSPACE -maxdepth=2

0 commit comments

Comments
 (0)