Skip to content

Commit 7e6d833

Browse files
Merge pull request #22 from HichemTab-tech/fix-workflow
Fix workflow
2 parents 33f440c + d15157e commit 7e6d833

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

.github/workflows/auto-bumper.yml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,37 @@ jobs:
8585
core.setFailed(`Unsupported event: ${eventName}. Use issue_comment or pull_request_review_comment.`);
8686
}
8787
88+
- name: Get PR branch name
89+
id: pr_branch
90+
if: steps.perm.outputs.allowed == 'true'
91+
uses: actions/github-script@v7
92+
with:
93+
script: |
94+
// Get the PR number from the issue_comment event
95+
const prNumber = context.payload.issue.pull_request
96+
? context.payload.issue.number
97+
: null;
98+
if (!prNumber) {
99+
core.setFailed('No PR number found in issue payload.');
100+
return;
101+
}
102+
// Fetch the PR data
103+
const { data: pr } = await github.rest.pulls.get({
104+
owner: context.repo.owner,
105+
repo: context.repo.repo,
106+
pull_number: prNumber,
107+
});
108+
if (pr.state !== 'open') {
109+
core.setFailed('PR is not open. Aborting.');
110+
return;
111+
}
112+
core.setOutput('branch', pr.head.ref);
113+
88114
- name: Checkout
89115
if: steps.perm.outputs.allowed == 'true'
90116
uses: actions/checkout@v4
91117
with:
92-
ref: ${{ github.event.pull_request.head.ref }}
118+
ref: ${{ steps.pr_branch.outputs.branch }}
93119
fetch-depth: 0
94120
token: ${{ secrets.GITHUB_TOKEN }}
95121

@@ -142,32 +168,6 @@ jobs:
142168
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
143169
core.setOutput('version', String(pkg.version));
144170
145-
- name: Get PR branch name
146-
id: pr_branch
147-
if: steps.perm.outputs.allowed == 'true'
148-
uses: actions/github-script@v7
149-
with:
150-
script: |
151-
// Get the PR number from the issue_comment event
152-
const prNumber = context.payload.issue.pull_request
153-
? context.payload.issue.number
154-
: null;
155-
if (!prNumber) {
156-
core.setFailed('No PR number found in issue payload.');
157-
return;
158-
}
159-
// Fetch the PR data
160-
const { data: pr } = await github.rest.pulls.get({
161-
owner: context.repo.owner,
162-
repo: context.repo.repo,
163-
pull_number: prNumber,
164-
});
165-
if (pr.state !== 'open') {
166-
core.setFailed('PR is not open. Aborting.');
167-
return;
168-
}
169-
core.setOutput('branch', pr.head.ref);
170-
171171
- name: Commit changes
172172
if: steps.perm.outputs.allowed == 'true'
173173
run: |

0 commit comments

Comments
 (0)