Skip to content

VYP: Edited workflow sync file #23

VYP: Edited workflow sync file

VYP: Edited workflow sync file #23

Workflow file for this run

name: Sync to Main
on:
push:
branches:
- 'services/**'
jobs:
sync:
if: github.ref_name != 'main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
path: source
- uses: actions/checkout@v4
with:
ref: main
path: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Sync to main
run: |
SERVICE_PATH="${{ github.ref_name }}"
cd main
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
# Remove old service directory
rm -rf "$SERVICE_PATH"
# Copy files from source to service directory
mkdir -p "$SERVICE_PATH"
cp -r ../source/* "$SERVICE_PATH/" 2>/dev/null || true
cp -r ../source/.[^.]* "$SERVICE_PATH/" 2>/dev/null || true
# Remove .git directory if copied
rm -rf "$SERVICE_PATH/.git"
git add .
if ! git diff --staged --quiet; then
git commit -m "Update $SERVICE_PATH"
git push origin main
fi