Skip to content

Commit

Permalink
update pr creation logic (#81)
Browse files Browse the repository at this point in the history
Signed-off-by: hlts2 <[email protected]>
  • Loading branch information
hlts2 authored Sep 16, 2023
1 parent 25bf363 commit c578dd6
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 64 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down
113 changes: 52 additions & 61 deletions act/merge-event.json → act/close-event-when-merge.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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": "[email protected]:vdaas/vald-ci-labs.git",
Expand All @@ -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}",
Expand All @@ -215,18 +215,18 @@
},
"body": "<!--- Provide a general summary of your changes in the Title above -->\r\n\r\n### Description:\r\n\r\n<!-- Describe your changes in detail -->\r\n<!-- It would be better to describe the details especially What changed and Why you changed -->\r\n\r\n### Related Issue:\r\n\r\n<!-- This project mainly accepts pull requests related to open issues -->\r\n<!-- NOTE: If suggesting a new feature or change, please discuss it in an issue first -->\r\n<!-- NOTE: If fixing a bug, there should be an issue describing it with steps to reproduce -->\r\n<!-- Please link to the issue here: -->\r\n\r\n### Versions:\r\n\r\n<!--- Please change the versions below along with your environment -->\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<!-- For completed items, change [ ] to [x]. -->\r\n<!-- NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open. -->\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<!-- Please tell us anything you would like to share to reviewers related this PR -->\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,
Expand Down Expand Up @@ -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": "[email protected]:vdaas/vald-ci-labs.git",
Expand All @@ -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}",
Expand All @@ -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}",
Expand All @@ -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}",
Expand Down Expand Up @@ -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": "[email protected]:vdaas/vald-ci-labs.git",
"stargazers_count": 0,
"stargazers_url": "https://api.github.com/repos/vdaas/vald-ci-labs/stargazers",
Expand Down Expand Up @@ -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"
}

0 comments on commit c578dd6

Please sign in to comment.