Refactor token storage from sessionStorage to localStorage for persis… #16
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 code from main to web | |
| on: | |
| push: | |
| branches: [main] | |
| paths-ignore: | |
| - 'data/**' | |
| - 'gitforge.config.json' | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Merge main into web (preserving web's data) | |
| run: | | |
| git fetch origin | |
| if git ls-remote --exit-code --heads origin web; then | |
| git checkout web | |
| git merge origin/main --no-ff --no-commit || true | |
| # Always restore web's personal files | |
| git checkout HEAD -- data/ gitforge.config.json | |
| git diff --cached --quiet || git commit -m "Sync code from main" | |
| git push origin web | |
| echo "pushed=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "web branch not found — creating it from main" | |
| git checkout -b web origin/main | |
| git push origin web | |
| echo "Created web branch from main." | |
| echo "pushed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| id: sync | |
| - name: Trigger deploy | |
| if: steps.sync.outputs.pushed == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'deploy.yml', | |
| ref: 'web' | |
| }) |