-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add bidirectional sync workflow #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,18 +31,20 @@ jobs: | |||||||
| fi | ||||||||
|
|
||||||||
| - name: Verify required configuration | ||||||||
| env: | ||||||||
| SYNC_PRIVATE_KEY: ${{ secrets.SYNC_PRIVATE_KEY }} | ||||||||
| APP_ID: ${{ steps.repo.outputs.app_id }} | ||||||||
| run: | | ||||||||
| if [[ -z "${{ secrets.SYNC_PRIVATE_KEY }}" ]]; then | ||||||||
| if [[ -z "$SYNC_PRIVATE_KEY" ]]; then | ||||||||
| echo "::error::SYNC_PRIVATE_KEY secret is not set. Please configure it in repo settings." | ||||||||
| exit 1 | ||||||||
| fi | ||||||||
| if [[ -z "${{ steps.repo.outputs.app_id }}" ]]; then | ||||||||
| if [[ -z "$APP_ID" ]]; then | ||||||||
| echo "::error::GitHub App ID variable not set. Configure EXADEV_APP_ID or ADPEAK_APP_ID." | ||||||||
| exit 1 | ||||||||
| fi | ||||||||
|
|
||||||||
| - name: Generate GitHub App token for other repo | ||||||||
| if: steps.check.outputs.skip != 'true' | ||||||||
| uses: tibdex/github-app-token@v2 | ||||||||
| id: token | ||||||||
| with: | ||||||||
|
|
@@ -51,7 +53,6 @@ jobs: | |||||||
|
|
||||||||
| - name: Sync to other repo | ||||||||
| id: sync | ||||||||
| if: steps.check.outputs.skip != 'true' | ||||||||
| env: | ||||||||
| TARGET_REPO: ${{ steps.repo.outputs.target }} | ||||||||
| TARGET_TOKEN: ${{ steps.token.outputs.token }} | ||||||||
|
|
@@ -84,8 +85,8 @@ jobs: | |||||||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||||||||
|
|
||||||||
| if git rebase target/main 2>/dev/null; then | ||||||||
| # Rebase successful - push directly to main | ||||||||
| git push target HEAD:main | ||||||||
| # Rebase successful - push with ci.skip to prevent triggering workflow loop | ||||||||
| git push target HEAD:main -o ci.skip | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The However, you can't modify commit messages during You need loop prevention. Options:
Suggested change
|
||||||||
| echo "skip_pr=true" >> "$GITHUB_OUTPUT" | ||||||||
| echo "::notice::Successfully rebased and synced ${COMMITS_BEHIND} commit(s) to ${TARGET_REPO}" | ||||||||
| else | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #!/bin/sh | ||
| # Run lint-staged after git commit --amend or rebase | ||
| # This catches formatting issues that pre-commit missed | ||
| npx lint-staged | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct solution. The One consideration: this will run lint-staged after every rewritten commit during an interactive rebase, which could slow down multi-commit rebases. This is standard behavior and acceptable. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good security fix. Moving secrets into environment variables prevents them from appearing in logs if the script encounters errors that echo the command.