VYP: Edited workflow sync file #11
Workflow file for this run
This file contains hidden or 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: Sync Service Folder to Main | |
on: | |
push: | |
branches: | |
- services/** | |
jobs: | |
sync-to-main: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source branch | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Extract service name from branch | |
id: extract | |
run: | | |
BRANCH_NAME="${GITHUB_REF#refs/heads/}" | |
SERVICE_NAME="${BRANCH_NAME#services/}" | |
echo "SERVICE_NAME=$SERVICE_NAME" >> $GITHUB_ENV | |
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV | |
- name: Checkout main branch | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
path: main_branch | |
- name: Copy updated service folder to main branch | |
run: | | |
SOURCE_PATH=services/${{ env.SERVICE_NAME }}/ | |
DEST_PATH=main_branch/services/${{ env.SERVICE_NAME }}/ | |
echo "Branch: ${{ env.BRANCH_NAME }}" | |
echo "Service: ${{ env.SERVICE_NAME }}" | |
echo "Source: $SOURCE_PATH" | |
echo "Destination: $DEST_PATH" | |
if [ -d "$SOURCE_PATH" ]; then | |
echo "✅ Found source folder: $SOURCE_PATH" | |
echo "📁 Files and directories in $SOURCE_PATH:" | |
ls -la "$SOURCE_PATH" | |
echo "🔍 Tree structure of $SOURCE_PATH:" | |
find "$SOURCE_PATH" -type f | head -20 | |
rm -rf "$DEST_PATH" | |
mkdir -p "$DEST_PATH" | |
cp -r "$SOURCE_PATH"/. "$DEST_PATH" | |
echo "✅ Copy completed" | |
else | |
echo "❌ Folder $SOURCE_PATH not found in branch." | |
echo "Available directories in current working directory:" | |
ls -la | |
echo "Looking for services directory:" | |
find . -name "services" -type d | |
echo "All directories containing 'service' or similar:" | |
find . -name "*service*" -type d | |
exit 1 | |
fi | |
- name: Commit and push to main | |
run: | | |
cd main_branch | |
git config user.name "github-actions" | |
git config user.email "github-actions@github.com" | |
git add services/${{ env.SERVICE_NAME }} | |
git commit -m "Sync ${{ github.ref_name }} → main/services/${{ env.SERVICE_NAME }}" || echo "No changes to commit" | |
git push origin main |