Skip to content

Commit

Permalink
✌️
Browse files Browse the repository at this point in the history
  • Loading branch information
tamaina committed Jan 22, 2024
1 parent 2f9eca3 commit 795b6d3
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,34 @@ jobs:
ruleset_id: ${{ vars.RULESET_ID_WITHIN_RELEASE }}
enforcement: disabled

- name: Check Mergeable
- name: 'Check Mergeable: gh pr view'
id: check-mergeable-gh-pr-view
run: |
echo "data=$(gh pr view ${{ inputs.pr_number }} --json reviewDecision,isDraft,mergeStateStatus,statusCheckRollup,mergeable)" >> $GITHUB_OUTPUT
- name: 'Check Mergeable: compare'
uses: actions/script@v7
env:
pr_number: ${{ inputs.pr_number }}
pr_data: ${{ steps.check-mergeable-gh-pr-view.outputs.data }}
with:
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: process.env.pr_number,
});
console.log(pr.data);
if (pr.data.mergeable !== true) {
throw new Error('Mergeable is not true');
const pr = JSON.parse(process.env.pr_data);
if (pr.isDraft) {
throw new Error('PR is draft');
}
if (pr.reviewDecision !== 'APPROVED') {
throw new Error(`reviewDecision is not APPROVED: ${pr.reviewDecision}`);
}
if (pr.mergeable !== 'MERGEABLE') {
throw new Error(`Not mergeable: ${pr.mergeable}`);
}
if (pr.mergeStateStatus !== 'CLEAN') {
throw new Error(`MergeStateStatus is not CLEAN: ${pr.mergeStateStatus}`);
}
if (pr.data.merge_state_status !== 'clean') {
throw new Error('Merge state status is not clean');
if (statusCheckRollup.find(s => s.conclusion !== 'SUCCESS')) {
throw new Error('Not all status checks are success');
}
#region if failured
#region if failed
- name: Re-enable the ruleset
uses: octokit/[email protected]
if: failure() && steps.app-token.outputs.token && vars.RULESET_ID_WITHIN_RELEASE
Expand Down

0 comments on commit 795b6d3

Please sign in to comment.