anny-booking-automation/.github/workflows/sync-to-public.yml

51 lines
1.4 KiB
YAML

name: Sync to Public Repo
on:
push:
branches:
- main
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Check if token is set
env:
TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }}
run: |
if [ -z "$TOKEN" ]; then
echo "❌ ERROR: PUBLIC_REPO_TOKEN secret is not set!"
exit 1
else
echo "✅ PUBLIC_REPO_TOKEN is set"
echo "Token starts with: ${TOKEN:0:4}..."
echo "Token length: ${#TOKEN}"
fi
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Remove sync workflow and push to public repo
env:
GH_TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }}
run: |
# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Create a temporary branch for the filtered push
git checkout -b temp-sync-branch
# Remove the sync workflow file
git rm .github/workflows/sync-to-public.yml
git commit -m "Remove sync workflow for public repo"
# Configure git to use gh for authentication
gh auth setup-git
# Push to public repo
git remote add public https://github.com/wiestju/anny-booking-automation.git
git push public temp-sync-branch:main --force