Refactor sync workflow by removing token verification steps and simplifying the sync process to public repo
This commit is contained in:
parent
e33306b6af
commit
81c360dca4
1 changed files with 3 additions and 30 deletions
33
.github/workflows/sync-to-public.yml
vendored
33
.github/workflows/sync-to-public.yml
vendored
|
|
@ -10,54 +10,27 @@ jobs:
|
||||||
sync:
|
sync:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
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
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Verify token works
|
- name: Sync to public repo
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }}
|
|
||||||
run: |
|
|
||||||
echo "Testing token with GitHub API..."
|
|
||||||
gh api user -q '.login' || echo "❌ Token invalid or no user scope"
|
|
||||||
echo "Testing repo access..."
|
|
||||||
gh api repos/wiestju/anny-booking-automation -q '.full_name' || echo "❌ No access to repo"
|
|
||||||
|
|
||||||
- name: Remove sync workflow and push to public repo
|
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }}
|
TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
# Configure git
|
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
# Create a temporary branch for the filtered push
|
# Create branch without sync workflow
|
||||||
git checkout -b temp-sync-branch
|
git checkout -b temp-sync-branch
|
||||||
|
|
||||||
# Remove the sync workflow file
|
|
||||||
git rm .github/workflows/sync-to-public.yml
|
git rm .github/workflows/sync-to-public.yml
|
||||||
git commit -m "Remove sync workflow for public repo"
|
git commit -m "Remove sync workflow for public repo"
|
||||||
|
|
||||||
# Remove ALL existing credential helpers and use store
|
# Setup credentials and push
|
||||||
git config --global --unset-all credential.helper || true
|
|
||||||
git config --global credential.helper store
|
git config --global credential.helper store
|
||||||
echo "https://x-access-token:${TOKEN}@github.com" > ~/.git-credentials
|
echo "https://x-access-token:${TOKEN}@github.com" > ~/.git-credentials
|
||||||
|
|
||||||
# Push to public repo
|
|
||||||
git remote add public https://github.com/wiestju/anny-booking-automation.git
|
git remote add public https://github.com/wiestju/anny-booking-automation.git
|
||||||
git push public temp-sync-branch:main --force
|
git push public temp-sync-branch:main --force
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue