Skip to content

Commit 5ddb355

Browse files
authored
Merge branch 'main' into chore/INFRA-3067-ref-duplication
2 parents b266dea + 3f447d6 commit 5ddb355

3 files changed

Lines changed: 34 additions & 15 deletions

File tree

.github/actions/check-skip-merge-queue/action.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ outputs:
3838
runs:
3939
using: composite
4040
steps:
41-
- name: Checkout repository
42-
uses: actions/checkout@v6
43-
with:
44-
fetch-depth: 0
45-
4641
- name: Get pull request details
4742
continue-on-error: true
4843
id: pr-details
@@ -90,15 +85,32 @@ runs:
9085
- name: Check if pull request is up-to-date with base branch
9186
continue-on-error: true
9287
id: up-to-date
93-
shell: bash
88+
uses: actions/github-script@v8
9489
env:
9590
BASE_REF: ${{ inputs.base-ref }}
9691
PR_BRANCH: ${{ steps.pr-details.outputs.pr-branch }}
9792
MERGE_QUEUE_POSITION: ${{ steps.pr-details.outputs.merge-queue-position }}
98-
run: |
99-
set -euo pipefail
100-
if git merge-base --is-ancestor "origin/${BASE_REF}" "origin/${PR_BRANCH}" && [ "${MERGE_QUEUE_POSITION}" -eq 1 ]; then
101-
echo "up-to-date=true" >> "$GITHUB_OUTPUT"
102-
else
103-
echo "up-to-date=false" >> "$GITHUB_OUTPUT"
104-
fi
93+
with:
94+
github-token: ${{ inputs.github-token }}
95+
script: |
96+
const { BASE_REF, PR_BRANCH, MERGE_QUEUE_POSITION } = process.env;
97+
98+
if (parseInt(MERGE_QUEUE_POSITION, 10) !== 1) {
99+
core.info(`Pull request is not first in the merge queue (position: ${MERGE_QUEUE_POSITION}).`);
100+
core.setOutput('up-to-date', 'false');
101+
return;
102+
}
103+
104+
const comparison = await github.rest.repos.compareCommitsWithBasehead({
105+
owner: context.repo.owner,
106+
repo: context.repo.repo,
107+
basehead: `${BASE_REF}...${PR_BRANCH}`,
108+
});
109+
110+
if (comparison.data.status === 'identical' || comparison.data.status === 'ahead') {
111+
core.info(`Pull request branch "${PR_BRANCH}" is up-to-date with base branch "${BASE_REF}".`);
112+
core.setOutput('up-to-date', 'true');
113+
} else {
114+
core.info(`Pull request branch "${PR_BRANCH}" is not up-to-date with base branch "${BASE_REF}".`);
115+
core.setOutput('up-to-date', 'false');
116+
}

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.4.2]
11+
12+
### Fixed
13+
14+
- Remove need for fetching repository by using GitHub API in skip merge queue check ([#204](https://github.com/MetaMask/github-tools/pull/204))
15+
1016
## [1.4.1]
1117

1218
### Fixed
@@ -82,7 +88,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8288
- Some inputs were renamed for consistency across actions.
8389
- Bump `actions/checkout` and `actions/setup-node` to `v6` ([#173](https://github.com/MetaMask/github-tools/pull/173))
8490

85-
[Unreleased]: https://github.com/MetaMask/github-tools/compare/v1.4.1...HEAD
91+
[Unreleased]: https://github.com/MetaMask/github-tools/compare/v1.4.2...HEAD
92+
[1.4.2]: https://github.com/MetaMask/github-tools/compare/v1.4.1...v1.4.2
8693
[1.4.1]: https://github.com/MetaMask/github-tools/compare/v1.4.0...v1.4.1
8794
[1.4.0]: https://github.com/MetaMask/github-tools/compare/v1.3.0...v1.4.0
8895
[1.3.0]: https://github.com/MetaMask/github-tools/compare/v1.2.0...v1.3.0

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/github-tools",
3-
"version": "1.4.1",
3+
"version": "1.4.2",
44
"private": true,
55
"description": "Tools for interacting with the GitHub API to do metrics gathering",
66
"repository": {

0 commit comments

Comments
 (0)