Yet another update on resources #73
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: sync-subtree-to-another-repo | |
#run-name: Sync a subtree of this repo to another repo | |
# run manually | |
#on: workflow_dispatch | |
on: | |
push: | |
paths: | |
- 'resources/**' | |
branches: | |
- 'github-workflows-commit-to-another-repo' | |
tags: | |
- '1.*' | |
jobs: | |
helloworld: | |
runs-on: ubuntu-22.04 | |
defaults: | |
run: | |
shell: bash | |
env: | |
TARGET_REPO_NAME: 'hello-octapus-public' | |
TARGET_REPO: '${{ github.repository_owner }}/hello-octapus-public' | |
PATH_TO_SYNC: resources/ | |
steps: | |
- run: >- | |
echo REPO_NAME=${GITHUB_REPOSITORY#*\/} >> $GITHUB_ENV | |
- run: git version | |
- run: pwd | |
- run: env | sort | |
- run: >- | |
echo "Github Ref: ${{ github.ref }}" | |
- run: uname -a | |
- run: whoami | |
- name: Dump github context | |
run: | | |
echo '${{ toJson(github) }}' | jq . | |
- run: >- | |
echo "NOW=$(date)" >> $GITHUB_ENV | |
- run: echo "NOW=$NOW" | |
- uses: actions/checkout@v3 | |
with: | |
repository: '${{ github.repository }}' | |
path: '${{ env.REPO_NAME }}' | |
submodules: true | |
token: ${{ secrets.REPO_READER_ACCESS_TOKEN }} | |
- uses: actions/checkout@v3 | |
with: | |
repository: '${{ env.TARGET_REPO }}' | |
path: '${{ env.TARGET_REPO_NAME }}' | |
submodules: true | |
token: ${{ secrets.REPO_WRITER_ACCESS_TOKEN }} | |
- run: ls -hal | |
- run: ls -hal | |
working-directory: '${{ github.workspace }}/${{ env.REPO_NAME }}' | |
- run: ls -hal | |
working-directory: '${{ github.workspace }}/${{ env.TARGET_REPO_NAME }}' | |
- run: rsync --version | |
- run: >- | |
rsync -avhi --delete --exclude '.gitkeep' ./${{ env.REPO_NAME }}/${{ env.PATH_TO_SYNC }} ./${{ env.TARGET_REPO_NAME }}/${{ env.PATH_TO_SYNC }} | |
- run: |- | |
git remote -v | |
git config user.name '${{ github.actor }}' | |
git config --global user.email '${{ github.actor }}@users.noreply.github.com' | |
working-directory: '${{ github.workspace }}/${{ env.TARGET_REPO_NAME }}' | |
- run: >- | |
git status --porcelain=v1 | |
working-directory: '${{ github.workspace }}/${{ env.TARGET_REPO_NAME }}' | |
#- run: >- | |
# [[ -n "$(git status --porcelain=v1)" ]] && git commit -a -m "Sync from ${GITHUB_REPOSITORY}:${PATH_TO_SYNC}" | |
# working-directory: '${{ github.workspace }}/${{ env.TARGET_REPO_NAME }}' | |
- run: >- | |
[[ -n "$(git status --porcelain=v1)" ]] && echo Y | |
working-directory: '${{ github.workspace }}/${{ env.TARGET_REPO_NAME }}' | |
#- run: >- | |
# git push origin master | |
# working-directory: '${{ github.workspace }}/${{ env.TARGET_REPO_NAME }}' | |