Skip to content

Support checking out tag (and switch to main) #5

Support checking out tag (and switch to main)

Support checking out tag (and switch to main) #5

Workflow file for this run

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