-
Notifications
You must be signed in to change notification settings - Fork 13
64 lines (49 loc) · 2.26 KB
/
Append_File_On_Merged_to_Main.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
name: Adding Files to Merged Main
run-name: ${{ github.actor }} is Adding Files to Merged Main
on:
pull_request:
types: [closed]
branches:
- main
jobs:
Adding_NAMESPACE_and_man_files:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
container: ruihe864/ccbr-github-playground:latest
steps:
- run: echo "Running test in Official R-base docker container with devtools"
- uses: actions/checkout@v3
with:
token: ${{secrets.GITHUB_TOKEN}}
- name: Generating files with Document
id: prepare-push
if: ${{ success() }}
run: |
export current_wd="/__w/${GITHUB_REPOSITORY#*/}/${GITHUB_REPOSITORY#*/}"
cd $current_wd
export MY_GIT_TOKEN=${{secrets.GITHUB_TOKEN}}
export MY_GIT_USERNAME=${{ github.actor }}
export MY_GIT_EMAIL=${{ github.event.pusher.email }}
git config --global user.name "$MY_GIT_USERNAME"
git config --global user.email "$MY_GIT_EMAIL"
git config --global url."https://api:[email protected]/".insteadOf "https://github.com/"
git config --global url."https://ssh:[email protected]/".insteadOf "ssh://[email protected]/"
git config --global url."https://git:[email protected]/".insteadOf "[email protected]:"
git config --global --add safe.directory "$current_wd"
git clone https://github.com/${GITHUB_REPOSITORY}.git
cd ${GITHUB_REPOSITORY#*/}
git checkout main
Rscript -e 'library(devtools);document()'
cat $(pwd)/NAMESPACE
git add ./NAMESPACE ./man/*
echo $(git commit -a -m "Adding auto-generated files") > commit_log.log
cat commit_log.log
echo "Performing check now"
export nothing_for_commit="$(grep -Po "nothing to commit" commit_log.log)"
if [ -n "${nothing_for_commit}" ]; then
echo "Commit check failed with message: $nothing_for_commit"
else
echo "Pushing changes now."
git push -f origin main
fi
echo "Process completed."