22 repository_dispatch :
33 types : [ merge-release-command ]
44
5- name : merge-release-command
5+ name : command-merge-release
6+ run-name : command-merge-release PR-${{ github.event.client_payload.github.payload.issue.number }}
67
78permissions :
89 contents : write
@@ -11,11 +12,6 @@ permissions:
1112
1213jobs :
1314 merge-release :
14- if : |
15- ${{ github.repository == 'carlspring/s3fs-nio' }} &&
16- ${{ (github.triggering_actor == 'carlspring' || github.triggering_actor == 'steve-todorov') == true }} &&
17- ${{ github.event.client_payload.slash_command.command == 'merge-release' }} &&
18- ${{ github.event_name == 'pull_request' }}
1915 runs-on : ubuntu-latest
2016 steps :
2117 - uses : actions/github-script@v6
@@ -25,15 +21,30 @@ jobs:
2521 # The method mappings can be found here: https://github.com/octokit/plugin-rest-endpoint-methods.js/blob/main/src/generated/endpoints.ts
2622 # Method parameters are available in the api docs: https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#merge-a-pull-request
2723 script : |
28- const response = await github.rest.pulls.listCommits({
24+ const pr = await github.rest.pulls.get({
25+ owner: context.repo.owner,
26+ repo: context.repo.repo,
27+ pull_number: '${{ github.event.client_payload.github.payload.issue.number }}'
28+ });
29+ const prTitle = pr.data.title
30+
31+ const isRelease = prTitle.includes("Release v")
32+ if(!isRelease) {
33+ console.log("")
34+ console.error("/merge-snapshot is supposed to be executed only on pull requests updating the version to snapshot!")
35+ console.log("")
36+ process.exit(1)
37+ }
38+
39+ const listCommits = await github.rest.pulls.listCommits({
2940 owner: context.repo.owner,
3041 repo: context.repo.repo,
3142 pull_number: '${{ github.event.client_payload.github.payload.issue.number }}',
3243 headers: { 'X-GitHub-Api-Version': '2022-11-28' }
3344 });
34- //console.log(response .data);
45+ //console.log(listCommits .data);
3546
36- const commits = [...response .data].map(c => c.commit);
47+ const commits = [...listCommits .data].map(c => c.commit);
3748 //console.log("Commits: ", commits);
3849
3950 const split = commits[0].message.split('\n');
4253 split.shift()
4354 let commit_message = (split.join('\n') + "\n\nCo-authored-by: " + commits[0].author.name + " <" + commits[0].author.email + ">").trim();
4455 console.log("Squash title: " + commit_title);
45- console.log("Squash message: " + commit_message);
56+ console.log("Squash message: \n" + commit_message + "\n/Squash message\n");
57+
4658 await github.rest.pulls.merge({
4759 owner: context.repo.owner,
4860 repo: context.repo.repo,
@@ -79,10 +91,25 @@ jobs:
7991 gh workflow run deploy-tag.yaml -f TAG=v${{ fromJSON(steps.release.outputs.result).version }}
8092
8193 # Add reaction to the comment
82- - name : Add reaction
94+ - name : Add success response
8395 uses : peter-evans/create-or-update-comment@v2
96+ if : ${{ success() }}
8497 with :
8598 token : ${{ secrets.GITHUB_TOKEN }}
8699 repository : ${{ github.event.client_payload.github.payload.repository.full_name }}
87100 comment-id : ${{ github.event.client_payload.github.payload.comment.id }}
88101 reaction-type : hooray
102+ body : |
103+ > Success: Action was successful! Check the [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
104+
105+ - name : Add failure response
106+ uses : peter-evans/create-or-update-comment@v2
107+ if : ${{ failure() }}
108+ with :
109+ token : ${{ secrets.GITHUB_TOKEN }}
110+ repository : ${{ github.event.client_payload.github.payload.repository.full_name }}
111+ comment-id : ${{ github.event.client_payload.github.payload.comment.id }}
112+ reaction-type : -1
113+ body : |
114+ > FAILURE: Action failed! Check the [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
115+
0 commit comments