Skip to content

Commit 6b11965

Browse files
committed
Yet another update on resources
1 parent ac5eee1 commit 6b11965

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

.github/workflows/learn-github-actions.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ jobs:
1818
helloworld:
1919
runs-on: ubuntu-22.04
2020
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/
2224
steps:
25+
- run: >-
26+
echo REPO_NAME=${GITHUB_REPOSITORY#*\/} >> $GITHUB_ENV
2327
- run: git version
2428
- run: pwd
2529
- run: env | sort
@@ -36,31 +40,33 @@ jobs:
3640
- uses: actions/checkout@v3
3741
with:
3842
repository: '${{ github.repository }}'
39-
path: 'hello-octapus'
43+
path: '${{ env.REPO_NAME }}'
4044
submodules: true
4145
token: ${{ secrets.REPO_READER_ACCESS_TOKEN }}
4246
- uses: actions/checkout@v3
4347
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 }}'
4650
submodules: true
4751
token: ${{ secrets.REPO_WRITER_ACCESS_TOKEN }}
4852
- run: ls -hal
4953
- run: ls -hal
50-
working-directory: '${{ github.workspace }}/hello-octapus'
54+
working-directory: '${{ github.workspace }}/${{ env.REPO_NAME }}'
5155
- run: ls -hal
52-
working-directory: '${{ github.workspace }}/hello-octapus-public'
56+
working-directory: '${{ github.workspace }}/${{ env.TARGET_REPO_NAME }}'
5357
- run: rsync --version
5458
- 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 }}
5660
- run: |-
5761
git status
5862
git remote -v
5963
git config user.name '${{ github.actor }}'
6064
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: >-
6570
git push origin master
66-
working-directory: '${{ github.workspace }}/hello-octapus-public'
71+
working-directory: '${{ github.workspace }}/${{ env.TARGET_REPO_NAME }}'
72+

resources/hello.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Hello (Github Actions) World
1+
Hello (Github Actions) World!!

0 commit comments

Comments
 (0)