diff --git a/.github/workflows/language-reference.yaml b/.github/workflows/language-reference.yaml index ec134ec35ffe..ae2cf2d7dfcc 100644 --- a/.github/workflows/language-reference.yaml +++ b/.github/workflows/language-reference.yaml @@ -70,19 +70,45 @@ jobs: backport-to-main: name: Create pull request with backport to main permissions: - pull-requests: write # for repo-sync/pull-request to create a PR + contents: write # it pushes a new branch + pull-requests: write # it creates a pr + env: + GITHUB_TOKEN: ${{ github.token }} + BRANCH_NAME: reference-merge-${{ github.event.head_commit.id }} runs-on: ubuntu-latest if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' steps: - uses: actions/checkout@v3 - - uses: repo-sync/pull-request@v2 with: - destination_branch: main - pr_label: area:documentation - pr_title: Sync with the stable documentation branch - pr_body: | - This pull request is syncing the main with changes from language-reference-stable. + fetch-depth: 0 + + - name: Sync files with main + run: | + Retained=`cat .github/workflows/reference-sync/paths.txt` + git restore --source=origin/main -- . + echo "$Retained" | xargs git restore -- - It was created automatically after ${{ github.event.head_commit.id }} by @${{ github.event.head_commit.author.username }} - pr_assignee: ${{ github.event.head_commit.author.username }} + - name: Commit + run: | + git config --global user.email "noreply@github.com" + git config --global user.name "github-actions[bot]" + git add -A . + git commit -m "Sync the documentation branch" + - name: Push + run: | + Url=${{ github.server_url }} + Server=${Url#*://} + Scheme=${Url%%://*} + Remote=${Scheme}://${{ github.token }}@${Server}/${{ github.repository }} + git push $Remote HEAD:refs/heads/$BRANCH_NAME + + - name: Prepare the message and create a pull request + run: | + <.github/workflows/reference-sync/pr-template.md sed -E " + s^<>^${{ github.event.head_commit.id }}^g; + s^<>^${{ github.event.head_commit.author.username }}^g; + s^<>^${Url}/${{ github.repository }}^g; + s^<>^${BRANCH_NAME}^g; + " \ + | hub pull-request -f -b main -h ${BRANCH_NAME} -a ${{ github.event.head_commit.author.username }} -l area:documentation -F - diff --git a/.github/workflows/reference-sync/paths.txt b/.github/workflows/reference-sync/paths.txt new file mode 100644 index 000000000000..fa2d3d8dacf5 --- /dev/null +++ b/.github/workflows/reference-sync/paths.txt @@ -0,0 +1,9 @@ +.github/workflows +changelogs +docs +scaladoc +scaladoc-js +scaladoc-testcases +scaladoc +CONTRIBUTING.md +MAINTENANCE.md \ No newline at end of file diff --git a/.github/workflows/reference-sync/pr-template.md b/.github/workflows/reference-sync/pr-template.md new file mode 100644 index 000000000000..1d2554f17ec6 --- /dev/null +++ b/.github/workflows/reference-sync/pr-template.md @@ -0,0 +1,5 @@ +Sync with the stable documentation branch + +This pull request is syncing the main with changes from language-reference-stable. + +It was created automatically after <> by @<>. Due to how GitHub calculates the diff for PRs, the `Files changed` tab will contain incorrect information. The correct diff can be found [here](<>/compare/main..<>). \ No newline at end of file