-
Notifications
You must be signed in to change notification settings - Fork 13
chore: 上流リポジトリの変更を取り込むためのGithub Actionsのworkflowを追加 #332
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
Open
3w36zj6
wants to merge
2
commits into
main
Choose a base branch
from
feature/add-workflow-to-merge-upstream-changes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+105
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # typst-jp/docs repository specific merge strategies | ||
| .github/workflows/* merge=ours | ||
| .github/ISSUE_TEMPLATE/* merge=ours | ||
| README.md merge=ours | ||
| CONTRIBUTING.md merge=ours |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| name: Merge upstream changes | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| upstream_ref: | ||
| description: "Upstream tag to merge" | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| merge-upstream: | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | ||
|
|
||
| - name: Configure Git | ||
| run: | | ||
| git config --global user.name 'GitHub Actions' | ||
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
| # Set up 'ours' merge driver | ||
| git config --global merge.ours.driver true | ||
|
|
||
| - name: Create new branch | ||
| run: | | ||
| git checkout -b feature/merge-upstream-${{ github.event.inputs.upstream_ref }} | ||
|
|
||
| - name: Add upstream remote | ||
| run: | | ||
| git remote add upstream https://github.com/typst/typst.git | ||
| git fetch upstream | ||
|
|
||
| - name: Attempt merge with commit markers | ||
| run: | | ||
| # Try to merge but allow conflicts | ||
| TARGET_COMMIT=$(git rev-parse ${{ github.event.inputs.upstream_ref }}) | ||
| git merge --no-commit --no-ff --allow-unrelated-histories $TARGET_COMMIT || true | ||
|
|
||
| # Remove upstream `.github/` directory | ||
| git checkout HEAD -- .github/ | ||
| git reset HEAD .github/ | ||
|
|
||
3w36zj6 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Commit the merge with conflict markers | ||
| git commit -a -m "Merge upstream changes from ${{ github.event.inputs.upstream_ref }}" | ||
|
|
||
| - name: Push branch | ||
| run: | | ||
| git push --force origin feature/merge-upstream-${{ github.event.inputs.upstream_ref }} | ||
|
|
||
| - name: Create Pull Request | ||
| id: create-pr | ||
| uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 | ||
| env: | ||
| PR_BODY: | | ||
| > [!CAUTION] | ||
| > コンフリクトの解消のため、このPull Requestは必ず**Create a merge commit**でマージしてください。 | ||
|
|
||
| このPull Requestでは、[上流リポジトリ](https://github.com/typst/typst)の[`${{ github.event.inputs.upstream_ref }}`](https://github.com/typst/typst/releases/tag/${{ github.event.inputs.upstream_ref }})の変更をマージします。 | ||
|
|
||
| with: | ||
| script: | | ||
| const pr = await github.rest.pulls.create({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| head: "feature/merge-upstream-${{ github.event.inputs.upstream_ref }}", | ||
| base: "main", | ||
| title: "Merge upstream ${{ github.event.inputs.upstream_ref }}", | ||
| body: process.env.PR_BODY | ||
| }); | ||
| core.setOutput("pr_number", pr.data.number); | ||
|
|
||
| - name: Check for conflict markers | ||
| id: check-conflicts | ||
| run: | | ||
| CONFLICT_FILES=$(git grep -l "^<<<<<<<\|^=======\|^>>>>>>>" HEAD || echo "") | ||
| if [ -n "$CONFLICT_FILES" ]; then | ||
| echo "has_conflicts=true" >> $GITHUB_OUTPUT | ||
| echo "conflict_files<<EOF" >> $GITHUB_OUTPUT | ||
| echo "$CONFLICT_FILES" >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Comment on Pull Request if conflicts found | ||
| if: steps.check-conflicts.outputs.has_conflicts == 'true' | ||
| uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 | ||
| with: | ||
| script: | | ||
| const files = `${{ steps.check-conflicts.outputs.conflict_files }}`.split('\n').filter(f => f); | ||
| const fileList = files.map(f => `- \`${f}\``).join('\n'); | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: ${{ steps.create-pr.outputs.pr_number }}, | ||
| body: `> [!WARNING]\n> コンフリクトマーカーが検出されました。以下のファイルを確認し、コンフリクトを解消してください。\n\n${fileList}` | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.