From c578dd6c8d3ab625ba6e05db98d19f7451215ea3 Mon Sep 17 00:00:00 2001 From: Hiroto Funakoshi Date: Sat, 16 Sep 2023 18:06:08 +0900 Subject: [PATCH] update pr creation logic (#81) Signed-off-by: hlts2 --- .github/workflows/pr.yaml | 7 +- ...event.json => close-event-when-merge.json} | 113 ++++++++---------- 2 files changed, 56 insertions(+), 64 deletions(-) rename act/{merge-event.json => close-event-when-merge.json} (93%) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 575f4746..54f93ace 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -23,11 +23,12 @@ on: env: TARGET_LABEL_NAME_PREFIX: "actions/backport/" + BACKPORT_BRANCH_NAME_PREFIX: "backport" jobs: dump-contexts-to-log: runs-on: ubuntu-latest - if: ${{ github.event.pull_request.merged == true }} + # if: ${{ github.event.pull_request.merged == true }} steps: - uses: actions/checkout@v3 - uses: ./.github/actions/dump-context @@ -68,8 +69,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} run: | for LABEL_NAME in ${LABEL_NAMES}; do - BRANCH_NAME=`echo "${LABEL_NAME}" | sed -e "s:^${TARGET_LABEL_NAME_PREFIX}::"` # e.g) release/vx.x, main - BACKPORT_BRANCH_NAME="backport/${BRANCH_NAME}/${GITHUB_HEAD_REF}" # e.g) backport/release/vx.x/{current branch name} + BRANCH_NAME=`echo "${LABEL_NAME}" | sed -e "s:^${TARGET_LABEL_NAME_PREFIX}::"` # e.g) release/vx.x, main + BACKPORT_BRANCH_NAME="${BACKPORT_BRANCH_NAME_PREFIX}/${BRANCH_NAME}/${GITHUB_HEAD_REF}" # e.g) backport/release/vx.x/{current branch name} echo "BRANCH_NAME=${BRANCH_NAME}" echo "BACKPORT_BRANCH_NAME=${BACKPORT_BRANCH_NAME}" diff --git a/act/merge-event.json b/act/close-event-when-merge.json similarity index 93% rename from act/merge-event.json rename to act/close-event-when-merge.json index ad0fdfab..554ddbca 100644 --- a/act/merge-event.json +++ b/act/close-event-when-merge.json @@ -1,14 +1,14 @@ { "token": "***", "job": "dump-contexts-to-log", - "ref": "main", - "sha": "523058db7e4a475d6b2ac6b96550ef1d87e4abbb", + "ref": "refs/heads/main", + "sha": "25bf363899402ee01bc0ee040ec760806744ce48", "repository": "vdaas/vald-ci-labs", "repository_owner": "vdaas", "repository_owner_id": "45956367", "repositoryUrl": "git://github.com/vdaas/vald-ci-labs.git", - "run_id": "6168372210", - "run_number": "43", + "run_id": "6187944557", + "run_number": "46", "retention_days": "90", "run_attempt": "1", "artifact_cache_size_limit": "10", @@ -19,13 +19,13 @@ "actor_id": "25459661", "actor": "hlts2", "triggering_actor": "hlts2", - "workflow": "Run backport PR creation", - "head_ref": "bugfix/lb/handler-logic", + "workflow": "Run backport PR", + "head_ref": "feature/ci/add-backport-to-other-branch", "base_ref": "main", "event_name": "pull_request", "event": { "action": "closed", - "number": 73, + "number": 80, "organization": { "avatar_url": "https://avatars.githubusercontent.com/u/45956367?v=4", "description": "Everything becomes Vector", @@ -43,30 +43,30 @@ "pull_request": { "_links": { "comments": { - "href": "https://api.github.com/repos/vdaas/vald-ci-labs/issues/73/comments" + "href": "https://api.github.com/repos/vdaas/vald-ci-labs/issues/80/comments" }, "commits": { - "href": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls/73/commits" + "href": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls/80/commits" }, - "html": { "href": "https://github.com/vdaas/vald-ci-labs/pull/73" }, + "html": { "href": "https://github.com/vdaas/vald-ci-labs/pull/80" }, "issue": { - "href": "https://api.github.com/repos/vdaas/vald-ci-labs/issues/73" + "href": "https://api.github.com/repos/vdaas/vald-ci-labs/issues/80" }, "review_comment": { "href": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls/comments{/number}" }, "review_comments": { - "href": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls/73/comments" + "href": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls/80/comments" }, "self": { - "href": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls/73" + "href": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls/80" }, "statuses": { - "href": "https://api.github.com/repos/vdaas/vald-ci-labs/statuses/228564dff4cea3c8be5e937d1a10c670804fbbd4" + "href": "https://api.github.com/repos/vdaas/vald-ci-labs/statuses/3a34e1bc995f2d357ae9b99d80ea967a43c65c9d" } }, "active_lock_reason": null, - "additions": 1, + "additions": 14, "assignee": null, "assignees": [], "author_association": "CONTRIBUTOR", @@ -167,9 +167,9 @@ }, "private": true, "pulls_url": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls{/number}", - "pushed_at": "2023-09-13T05:30:01Z", + "pushed_at": "2023-09-14T15:55:48Z", "releases_url": "https://api.github.com/repos/vdaas/vald-ci-labs/releases{/id}", - "size": 9754, + "size": 9847, "squash_merge_commit_message": "COMMIT_MESSAGES", "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", "ssh_url": "git@github.com:vdaas/vald-ci-labs.git", @@ -191,7 +191,7 @@ "watchers_count": 0, "web_commit_signoff_required": false }, - "sha": "61a6c343387f9919137d97d427d4382a0413f321", + "sha": "7d711d29855e26b400d3877569abc459e6bc6c87", "user": { "avatar_url": "https://avatars.githubusercontent.com/u/45956367?v=4", "events_url": "https://api.github.com/users/vdaas/events{/privacy}", @@ -215,18 +215,18 @@ }, "body": "\r\n\r\n### Description:\r\n\r\n\r\n\r\n\r\n### Related Issue:\r\n\r\n\r\n\r\n\r\n\r\n\r\n### Versions:\r\n\r\n\r\n\r\n- Go Version: 1.21.1\r\n- Docker Version: 20.10.8\r\n- Kubernetes Version: v1.28.1\r\n- NGT Version: 2.1.3\r\n\r\n### Checklist:\r\n\r\n\r\n\r\n\r\n- [ ] I have read the [CONTRIBUTING](https://github.com/vdaas/vald/blob/main/CONTRIBUTING.md) document and completed [our CLA agreement](https://cla-assistant.io/vdaas/vald).\r\n- [ ] I have checked open [Pull Requests](https://github.com/vdaas/vald/pulls) for the similar feature or fixes?\r\n\r\n### Special notes for your reviewer:\r\n\r\n\r\n", "changed_files": 1, - "closed_at": "2023-09-13T05:30:01Z", + "closed_at": "2023-09-14T15:55:49Z", "comments": 0, - "comments_url": "https://api.github.com/repos/vdaas/vald-ci-labs/issues/73/comments", + "comments_url": "https://api.github.com/repos/vdaas/vald-ci-labs/issues/80/comments", "commits": 1, - "commits_url": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls/73/commits", - "created_at": "2023-09-13T05:29:27Z", - "deletions": 0, - "diff_url": "https://github.com/vdaas/vald-ci-labs/pull/73.diff", + "commits_url": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls/80/commits", + "created_at": "2023-09-14T15:55:42Z", + "deletions": 14, + "diff_url": "https://github.com/vdaas/vald-ci-labs/pull/80.diff", "draft": false, "head": { - "label": "vdaas:bugfix/lb/handler-logic", - "ref": "bugfix/lb/handler-logic", + "label": "vdaas:feature/ci/add-backport-to-other-branch", + "ref": "feature/ci/add-backport-to-other-branch", "repo": { "allow_auto_merge": false, "allow_forking": false, @@ -320,9 +320,9 @@ }, "private": true, "pulls_url": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls{/number}", - "pushed_at": "2023-09-13T05:30:01Z", + "pushed_at": "2023-09-14T15:55:48Z", "releases_url": "https://api.github.com/repos/vdaas/vald-ci-labs/releases{/id}", - "size": 9754, + "size": 9847, "squash_merge_commit_message": "COMMIT_MESSAGES", "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", "ssh_url": "git@github.com:vdaas/vald-ci-labs.git", @@ -344,7 +344,7 @@ "watchers_count": 0, "web_commit_signoff_required": false }, - "sha": "228564dff4cea3c8be5e937d1a10c670804fbbd4", + "sha": "3a34e1bc995f2d357ae9b99d80ea967a43c65c9d", "user": { "avatar_url": "https://avatars.githubusercontent.com/u/45956367?v=4", "events_url": "https://api.github.com/users/vdaas/events{/privacy}", @@ -366,36 +366,27 @@ "url": "https://api.github.com/users/vdaas" } }, - "html_url": "https://github.com/vdaas/vald-ci-labs/pull/73", - "id": 1513219409, - "issue_url": "https://api.github.com/repos/vdaas/vald-ci-labs/issues/73", + "html_url": "https://github.com/vdaas/vald-ci-labs/pull/80", + "id": 1515975076, + "issue_url": "https://api.github.com/repos/vdaas/vald-ci-labs/issues/80", "labels": [ { "color": "5DF3C5", "default": false, "description": "", "id": 5953088589, - "name": "actions/backport/v1.6", + "name": "actions/backport/release/v1.7", "node_id": "LA_kwDODkzaps8AAAABYtTsTQ", - "url": "https://api.github.com/repos/vdaas/vald-ci-labs/labels/actions/backport/v1.6" - }, - { - "color": "fef2c0", - "default": false, - "description": "", - "id": 5956246594, - "name": "actions/backport/v1.7", - "node_id": "LA_kwDODkzaps8AAAABYwUcQg", "url": "https://api.github.com/repos/vdaas/vald-ci-labs/labels/actions/backport/v1.7" } ], "locked": false, "maintainer_can_modify": false, - "merge_commit_sha": "523058db7e4a475d6b2ac6b96550ef1d87e4abbb", + "merge_commit_sha": "25bf363899402ee01bc0ee040ec760806744ce48", "mergeable": null, "mergeable_state": "unknown", "merged": true, - "merged_at": "2023-09-13T05:30:01Z", + "merged_at": "2023-09-14T15:55:48Z", "merged_by": { "avatar_url": "https://avatars.githubusercontent.com/u/25459661?v=4", "events_url": "https://api.github.com/users/hlts2/events{/privacy}", @@ -417,20 +408,20 @@ "url": "https://api.github.com/users/hlts2" }, "milestone": null, - "node_id": "PR_kwDODkzaps5aMeVR", - "number": 73, - "patch_url": "https://github.com/vdaas/vald-ci-labs/pull/73.patch", + "node_id": "PR_kwDODkzaps5aW_Gk", + "number": 80, + "patch_url": "https://github.com/vdaas/vald-ci-labs/pull/80.patch", "rebaseable": null, "requested_reviewers": [], "requested_teams": [], "review_comment_url": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls/comments{/number}", "review_comments": 0, - "review_comments_url": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls/73/comments", + "review_comments_url": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls/80/comments", "state": "closed", - "statuses_url": "https://api.github.com/repos/vdaas/vald-ci-labs/statuses/228564dff4cea3c8be5e937d1a10c670804fbbd4", - "title": "Add todo comment", - "updated_at": "2023-09-13T05:30:02Z", - "url": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls/73", + "statuses_url": "https://api.github.com/repos/vdaas/vald-ci-labs/statuses/3a34e1bc995f2d357ae9b99d80ea967a43c65c9d", + "title": "Add backport workflow to other branches", + "updated_at": "2023-09-14T15:55:49Z", + "url": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls/80", "user": { "avatar_url": "https://avatars.githubusercontent.com/u/25459661?v=4", "events_url": "https://api.github.com/users/hlts2/events{/privacy}", @@ -537,9 +528,9 @@ }, "private": true, "pulls_url": "https://api.github.com/repos/vdaas/vald-ci-labs/pulls{/number}", - "pushed_at": "2023-09-13T05:30:01Z", + "pushed_at": "2023-09-14T15:55:48Z", "releases_url": "https://api.github.com/repos/vdaas/vald-ci-labs/releases{/id}", - "size": 9754, + "size": 9847, "ssh_url": "git@github.com:vdaas/vald-ci-labs.git", "stargazers_count": 0, "stargazers_url": "https://api.github.com/repos/vdaas/vald-ci-labs/stargazers", @@ -586,18 +577,18 @@ "ref_protected": false, "ref_type": "branch", "secret_source": "Actions", - "workflow_ref": "vdaas/vald-ci-labs/.github/workflows/pr.yaml@main", - "workflow_sha": "523058db7e4a475d6b2ac6b96550ef1d87e4abbb", + "workflow_ref": "vdaas/vald-ci-labs/.github/workflows/pr.yaml@refs/heads/main", + "workflow_sha": "25bf363899402ee01bc0ee040ec760806744ce48", "workspace": "/home/runner/work/vald-ci-labs/vald-ci-labs", "action": "__self", "event_path": "/home/runner/work/_temp/_github_workflow/event.json", "action_repository": "", "action_ref": "", - "path": "/home/runner/work/_temp/_runner_file_commands/add_path_26f170f6-4889-4d3b-8785-0061d5739107", - "env": "/home/runner/work/_temp/_runner_file_commands/set_env_26f170f6-4889-4d3b-8785-0061d5739107", - "step_summary": "/home/runner/work/_temp/_runner_file_commands/step_summary_26f170f6-4889-4d3b-8785-0061d5739107", - "state": "/home/runner/work/_temp/_runner_file_commands/save_state_26f170f6-4889-4d3b-8785-0061d5739107", - "output": "/home/runner/work/_temp/_runner_file_commands/set_output_26f170f6-4889-4d3b-8785-0061d5739107", + "path": "/home/runner/work/_temp/_runner_file_commands/add_path_e852f526-9044-41c4-86b3-d12d32c7c9e0", + "env": "/home/runner/work/_temp/_runner_file_commands/set_env_e852f526-9044-41c4-86b3-d12d32c7c9e0", + "step_summary": "/home/runner/work/_temp/_runner_file_commands/step_summary_e852f526-9044-41c4-86b3-d12d32c7c9e0", + "state": "/home/runner/work/_temp/_runner_file_commands/save_state_e852f526-9044-41c4-86b3-d12d32c7c9e0", + "output": "/home/runner/work/_temp/_runner_file_commands/set_output_e852f526-9044-41c4-86b3-d12d32c7c9e0", "action_path": "/home/runner/work/vald-ci-labs/vald-ci-labs/./.github/actions/dump-context", "action_status": "success" }