18
18
helloworld :
19
19
runs-on : ubuntu-22.04
20
20
env :
21
- FOO : bar
21
+ TARGET_REPO_NAME : ' hello-octapus-public'
22
+ TARGET_REPO : ' ${{ github.repository_owner }}/hello-octapus-public'
23
+ PATH_TO_SYNC : resources/
22
24
steps :
25
+ - run : >-
26
+ echo REPO_NAME=${GITHUB_REPOSITORY#*\/} >> $GITHUB_ENV
23
27
- run : git version
24
28
- run : pwd
25
29
- run : env | sort
@@ -36,31 +40,33 @@ jobs:
36
40
- uses : actions/checkout@v3
37
41
with :
38
42
repository : ' ${{ github.repository }}'
39
- path : ' hello-octapus '
43
+ path : ' ${{ env.REPO_NAME }} '
40
44
submodules : true
41
45
token : ${{ secrets.REPO_READER_ACCESS_TOKEN }}
42
46
- uses : actions/checkout@v3
43
47
with :
44
- repository : ' ${{ github.repository_owner }}/hello-octapus-public '
45
- path : ' hello-octapus-public '
48
+ repository : ' ${{ env.TARGET_REPO }}'
49
+ path : ' ${{ env.TARGET_REPO_NAME }} '
46
50
submodules : true
47
51
token : ${{ secrets.REPO_WRITER_ACCESS_TOKEN }}
48
52
- run : ls -hal
49
53
- run : ls -hal
50
- working-directory : ' ${{ github.workspace }}/hello-octapus '
54
+ working-directory : ' ${{ github.workspace }}/${{ env.REPO_NAME }} '
51
55
- run : ls -hal
52
- working-directory : ' ${{ github.workspace }}/hello-octapus-public '
56
+ working-directory : ' ${{ github.workspace }}/${{ env.TARGET_REPO_NAME }} '
53
57
- run : rsync --version
54
58
- run : >-
55
- rsync -avhi --delete --exclude '.gitkeep' ${{ github.workspace }}/hello-octapus/resources/ ${{ github.workspace }}/hello-octapus-public/resources/
59
+ rsync -avhi --delete --exclude '.gitkeep' ./ ${{ env.REPO_NAME }}/${{ env.PATH_TO_SYNC }} ./ ${{ env.TARGET_REPO_NAME }}/${{ env.PATH_TO_SYNC }}
56
60
- run : |-
57
61
git status
58
62
git remote -v
59
63
git config user.name '${{ github.actor }}'
60
64
git config --global user.email '${{ github.actor }}@users.noreply.github.com'
61
- working-directory: '${{ github.workspace }}/hello-octapus-public'
62
- - run : |-
63
- git add resources && git status
64
- git commit -am 'Sync `resources/` folder from ${{ github.repository }}'
65
+ working-directory: '${{ github.workspace }}/${{ env.TARGET_REPO_NAME }}'
66
+ - run : >-
67
+ [[ -n "$(git status --porcelain=v1)" ]] && git commit -a -m "Sync from ${GITHUB_REPOSITORY}:${PATH_TO_SYNC}"
68
+ working-directory: '${{ github.workspace }}/${{ env.TARGET_REPO_NAME }}'
69
+ - run : >-
65
70
git push origin master
66
- working-directory: '${{ github.workspace }}/hello-octapus-public'
71
+ working-directory: '${{ github.workspace }}/${{ env.TARGET_REPO_NAME }}'
72
+
0 commit comments