Create DemoSync.yaml #1
Workflow file for this run
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: DemoSync | |
on: | |
push: | |
tags: | |
- '*' | |
env: | |
TARGET_REPOSITORY: 'https://x-access-token:${{ secrets.DEMO_REPOSITORY_PAT }}@github.com/diploi/nextjs-postgresql-template-demo.git' | |
TAG_NAME: '${GITHUB_REF#refs/tags/}' | |
jobs: | |
sync-folder: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source repository | |
uses: actions/checkout@v2 | |
- name: Sync initialProject folder and push tag | |
run: | | |
# Configure git | |
git config --global user.email "[email protected]" | |
git config --global user.name "Demo Sync" | |
# Clone the target repository using HTTPS and PAT for authentication | |
git clone ${{ env.TARGET_REPOSITORY }} temp_repo | |
cd temp_repo | |
# Sync the folder | |
rsync -av --delete --exclude='.git/' ../initialProject/ ./ | |
# Commit and push the changes, if there are any | |
git add . | |
git diff --quiet && git diff --staged --quiet || (git commit -m "Commit sync" && git push origin main) | |
# Tag and push the tag | |
git tag ${{ env.TAG_NAME }} | |
git push origin --tags |