From 73ca9b2d8ca1f8fcb40ae3ce21de9587cd632b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Fri, 3 Feb 2023 10:46:46 +0100 Subject: [PATCH 1/2] Add safer way of syncing docs --- .github/workflows/language-reference.yaml | 44 +++++++++++++++---- .github/workflows/reference-sync/paths.txt | 3 ++ .../workflows/reference-sync/pr-template.md | 5 +++ 3 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/reference-sync/paths.txt create mode 100644 .github/workflows/reference-sync/pr-template.md diff --git a/.github/workflows/language-reference.yaml b/.github/workflows/language-reference.yaml index ec134ec35ffe..ac8523414ccf 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 }} 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: | + BranchName=reference-merge-${{ github.event.head_commit.id }} + Url=${{ github.server_url }} + Server=${Url#*://} + Scheme=${Url%%://*} + Remote=${Scheme}://${{ github.token }}@${Server}/${{ github.repository }} + git push $Remote HEAD:refs/heads/$BranchName + + - name: Format 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^<>^${BranchName}^g; + " \ + | hub pull-request -f -b main -h ${BranchName} -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..094ca7760ff8 --- /dev/null +++ b/.github/workflows/reference-sync/paths.txt @@ -0,0 +1,3 @@ +.github/workflows +scaladoc +docs \ 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 From 5ea3a2b8fb19010c8c9e99ea01fcaeb47ee82d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Marks?= Date: Thu, 9 Feb 2023 12:49:12 +0100 Subject: [PATCH 2/2] Add more paths to synclist --- .github/workflows/language-reference.yaml | 10 +++++----- .github/workflows/reference-sync/paths.txt | 8 +++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/language-reference.yaml b/.github/workflows/language-reference.yaml index ac8523414ccf..ae2cf2d7dfcc 100644 --- a/.github/workflows/language-reference.yaml +++ b/.github/workflows/language-reference.yaml @@ -74,6 +74,7 @@ jobs: 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: @@ -96,19 +97,18 @@ jobs: - name: Push run: | - BranchName=reference-merge-${{ github.event.head_commit.id }} Url=${{ github.server_url }} Server=${Url#*://} Scheme=${Url%%://*} Remote=${Scheme}://${{ github.token }}@${Server}/${{ github.repository }} - git push $Remote HEAD:refs/heads/$BranchName + git push $Remote HEAD:refs/heads/$BRANCH_NAME - - name: Format the message and create a pull request + - 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^<>^${BranchName}^g; + s^<>^${BRANCH_NAME}^g; " \ - | hub pull-request -f -b main -h ${BranchName} -a ${{ github.event.head_commit.author.username }} -l area:documentation -F - + | 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 index 094ca7760ff8..fa2d3d8dacf5 100644 --- a/.github/workflows/reference-sync/paths.txt +++ b/.github/workflows/reference-sync/paths.txt @@ -1,3 +1,9 @@ .github/workflows +changelogs +docs scaladoc -docs \ No newline at end of file +scaladoc-js +scaladoc-testcases +scaladoc +CONTRIBUTING.md +MAINTENANCE.md \ No newline at end of file