Manual Sync Files on Merge #18
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: Manual Sync Files on Merge | |
on: | |
pull_request: | |
branches: | |
- main | |
types: [closed] | |
workflow_dispatch: | |
env: | |
SOURCE_DIR: ./src/ | |
TARGET_OWNER: larshinueber | |
TARGET_REPO: foo-space | |
TARGET_DIR: foo-space/docs/source/_src_getting_started/_src_examples/notebooks/ | |
jobs: | |
sync: | |
# if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source repository | |
uses: actions/checkout@v4 | |
- name: Checkout target repository | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ env.TARGET_OWNER }}/${{ env.TARGET_REPO }} | |
token: ${{ secrets.GH_PAT }} | |
ref: main | |
path: ./${{ env.TARGET_REPO }} | |
- name: Create new branch | |
run: | | |
cd ./${{ env.TARGET_REPO }} | |
# TODO: how can multiple open PRs be handled? | |
git checkout -b man-repo-sync | |
cd .. | |
- name: Delete old files | |
run: | | |
rm -rf ${{ env.TARGET_DIR }} | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.11' | |
- name: Copy new files | |
run: | | |
# cd .. | |
echo ${{ github.workspace }} | |
# TODO: generalized, sync all .ipynb files | |
python .github/scripts/copy_notebooks.py ${{ env.SOURCE_DIR }} ${{ env.TARGET_DIR }} | |
- name: Push changes | |
run: | | |
cd ./${{ env.TARGET_REPO }} | |
git config --global user.email github-actions | |
git config --global user.name [email protected] | |
git add . | |
git commit -m "Auto-update foo-space examples" | |
git push --set-upstream origin man-repo-sync | |
gh pr create --title "Auto-update foo-space examples" --body "Please manually remove all non *.ipynp-files." --base main | |
env: | |
GH_TOKEN: ${{ secrets.GH_PAT }} |