From 3063db7f51f5b9c10d5ba88c8243eab3d0a9c131 Mon Sep 17 00:00:00 2001 From: David Cui Date: Wed, 23 Feb 2022 09:56:15 -0800 Subject: [PATCH 1/4] add auto-backport functionality for reporting Signed-off-by: David Cui --- .github/workflows/backport.yml | 16 ++++++++++++++++ dashboards-reports/DEVELOPER_GUIDE.md | 6 ++++++ 2 files changed, 22 insertions(+) create mode 100644 .github/workflows/backport.yml diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml new file mode 100644 index 00000000..c0d07fef --- /dev/null +++ b/.github/workflows/backport.yml @@ -0,0 +1,16 @@ +name: Backport +on: + pull_request: + types: + - closed + - labeled + +jobs: + backport: + runs-on: ubuntu-latest + name: Backport + steps: + - name: Backport + uses: tibdex/backport@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/dashboards-reports/DEVELOPER_GUIDE.md b/dashboards-reports/DEVELOPER_GUIDE.md index a79bd195..b721ad8b 100644 --- a/dashboards-reports/DEVELOPER_GUIDE.md +++ b/dashboards-reports/DEVELOPER_GUIDE.md @@ -44,3 +44,9 @@ Example output: `./build/reports-dashboards-0.0.1.zip` - `yarn test:jest` Runs the plugin tests. + +### Backports + +The Github workflow in [`backport.yml`](../.github/workflows/backport.yml) creates backport PRs automatically when the +original PR with an appropriate label `backport ` is merged to main with the backport workflow +run successfully on the PR. For example, if a PR on main needs to be backported to `1.x` branch, add a label \ No newline at end of file From cff0144f53656dfbcce61a74cf8b7135ef36faee Mon Sep 17 00:00:00 2001 From: David Cui Date: Wed, 23 Feb 2022 10:25:02 -0800 Subject: [PATCH 2/4] fixed line break formatting and added rest of the backport documentation Signed-off-by: David Cui --- dashboards-reports/DEVELOPER_GUIDE.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dashboards-reports/DEVELOPER_GUIDE.md b/dashboards-reports/DEVELOPER_GUIDE.md index b721ad8b..34586907 100644 --- a/dashboards-reports/DEVELOPER_GUIDE.md +++ b/dashboards-reports/DEVELOPER_GUIDE.md @@ -47,6 +47,8 @@ Example output: `./build/reports-dashboards-0.0.1.zip` ### Backports -The Github workflow in [`backport.yml`](../.github/workflows/backport.yml) creates backport PRs automatically when the -original PR with an appropriate label `backport ` is merged to main with the backport workflow -run successfully on the PR. For example, if a PR on main needs to be backported to `1.x` branch, add a label \ No newline at end of file +The Github workflow in [`backport.yml`](.github/workflows/backport.yml) creates backport PRs automatically when the original PR +with an appropriate label `backport ` is merged to main with the backport workflow run successfully on the +PR. For example, if a PR on main needs to be backported to `1.x` branch, add a label `backport 1.x` to the PR and make sure the +backport workflow runs on the PR along with other checks. Once this PR is merged to main, the workflow will create a backport PR +to the `1.x` branch. \ No newline at end of file From f1306c342625d6c064b5ea919d9e39dac9ee53b8 Mon Sep 17 00:00:00 2001 From: David Cui Date: Wed, 23 Feb 2022 14:19:53 -0800 Subject: [PATCH 3/4] update backport workflow and add auto-delete Signed-off-by: David Cui --- .github/workflows/backport.yml | 18 +++++++++++++++--- .github/workflows/delete_backport_branch.yml | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/delete_backport_branch.yml diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index c0d07fef..e47d8d88 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -1,6 +1,6 @@ name: Backport on: - pull_request: + pull_request_target: types: - closed - labeled @@ -8,9 +8,21 @@ on: jobs: backport: runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write name: Backport steps: + - name: GitHub App token + id: github_app_token + uses: tibdex/github-app-token@v1.5.0 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + installation_id: 22958780 + - name: Backport - uses: tibdex/backport@v1 + uses: VachaShah/backport@v1.1.4 with: - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ steps.github_app_token.outputs.token }} + branch_name: backport/backport-${{ github.event.number }} diff --git a/.github/workflows/delete_backport_branch.yml b/.github/workflows/delete_backport_branch.yml new file mode 100644 index 00000000..387a124b --- /dev/null +++ b/.github/workflows/delete_backport_branch.yml @@ -0,0 +1,15 @@ +name: Delete merged branch of the backport PRs +on: + pull_request: + types: + - closed + +jobs: + delete-branch: + runs-on: ubuntu-latest + if: startsWith(github.event.pull_request.head.ref,'backport/') + steps: + - name: Delete merged branch + uses: SvanBoxel/delete-merged-branch@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From da56ed9b451474951cd4644ece1e9bd47c127ada Mon Sep 17 00:00:00 2001 From: David Cui Date: Wed, 23 Feb 2022 14:50:48 -0800 Subject: [PATCH 4/4] fix link to backport workflow Signed-off-by: David Cui --- dashboards-reports/DEVELOPER_GUIDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboards-reports/DEVELOPER_GUIDE.md b/dashboards-reports/DEVELOPER_GUIDE.md index 34586907..8f54891f 100644 --- a/dashboards-reports/DEVELOPER_GUIDE.md +++ b/dashboards-reports/DEVELOPER_GUIDE.md @@ -47,7 +47,7 @@ Example output: `./build/reports-dashboards-0.0.1.zip` ### Backports -The Github workflow in [`backport.yml`](.github/workflows/backport.yml) creates backport PRs automatically when the original PR +The Github workflow in [`backport.yml`](../.github/workflows/backport.yml) creates backport PRs automatically when the original PR with an appropriate label `backport ` is merged to main with the backport workflow run successfully on the PR. For example, if a PR on main needs to be backported to `1.x` branch, add a label `backport 1.x` to the PR and make sure the backport workflow runs on the PR along with other checks. Once this PR is merged to main, the workflow will create a backport PR