Skip to content

adding image

adding image #16

name: Push Starter Project Subdirectory to Another Repo
on:
push:
branches:
- main
paths:
- "apps/next-wordpress-starter/**"
jobs:
push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Git Config
run: |
git config --global user.name 'GitHub Action Bot'
git config --global user.email 'action@github.com'
- name: Set up SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > private_key
sed -i 's/\\n/\n/g' private_key
chmod 600 private_key
ssh-keyscan github.com >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
- name: Clone the destination repository using SSH
run: |
GIT_SSH_COMMAND="ssh -i private_key -o StrictHostKeyChecking=no" git clone git@github.com:CalebBarnes/nextwp-starter.git temp_repo
- name: Copy files to the temporary directory
run: |
rsync -av --exclude='.git' --delete apps/next-wordpress-starter/ temp_repo/
- name: Push to the destination repository
run: |
cd temp_repo
git add .
git commit -m "Mirrored from nextwp repository"
GIT_SSH_COMMAND="ssh -i ../private_key -o StrictHostKeyChecking=no" git push origin main