Skip to content

Commit 453d1b0

Browse files
committed
fix(deploy-pre): Simplify workflow
Changes to simplify step 3 and 4.
1 parent 736d9e0 commit 453d1b0

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed

.github/workflows/deploy-pre-chatbot.yml

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,45 +32,36 @@ jobs:
3232
- name: Extract PR Branch
3333
if: steps.check_command.outputs.valid == 'true'
3434
id: pr_details
35-
uses: actions/github-script@v6
36-
with:
37-
script: |
38-
const issue = context.payload.issue;
39-
40-
// Check if the issue is related to a pull request
41-
if (!issue.pull_request || !issue.pull_request.url) {
42-
throw new Error("This comment is not associated with a pull request.");
43-
}
44-
45-
const pr_url = issue.pull_request.url;
46-
47-
// Fetch pull request details using the GitHub API
48-
const pr = await github.rest.pulls.get({
49-
owner: context.repo.owner,
50-
repo: context.repo.repo,
51-
pull_number: context.payload.issue.number
52-
});
53-
54-
// Log the PR details for debugging
55-
console.log("PR details:", pr.data);
56-
57-
// Ensure we have the correct branch info
58-
if (!pr.data.head || !pr.data.head.ref) {
59-
throw new Error("Cannot find branch reference in the pull request.");
60-
}
61-
62-
const branch = pr.data.head.ref; // This is the branch name of the PR
63-
console.log("PR branch:", branch);
64-
65-
return branch;
66-
result-encoding: string
35+
run: |
36+
PR_NUMBER="${{ github.event.issue.number }}"
37+
REPO_OWNER="${{ github.repository_owner }}"
38+
REPO_NAME="${{ github.event.repository.name }}"
39+
40+
echo "Fetching PR details for PR #$PR_NUMBER"
41+
42+
# Use GitHub REST API to fetch the PR details
43+
PR_DETAILS=$(curl -s \
44+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
45+
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER")
46+
6747
48+
# Log the full PR details for debugging purposes
49+
echo "PR Details: $PR_DETAILS"
50+
51+
# Extract the branch name (head.ref)
52+
BRANCH=$(echo "$PR_DETAILS" | jq -r '.head.ref')
53+
54+
# Output the branch name for debugging
55+
echo "PR branch: $BRANCH"
56+
57+
# Set the branch name as an output
58+
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
6859
6960
# Step 4: Debug PR Branch
7061
- name: Debug PR Branch
7162
if: steps.check_command.outputs.valid == 'true'
7263
run: |
73-
echo "Branch: ${{ steps.pr_details.outputs.result }}"
64+
echo "Branch: ${{ steps.pr_details.outputs.branch }}"
7465
7566
# Step 5: Trigger Deploy Workflow
7667
- name: Trigger Deploy Workflow

0 commit comments

Comments
 (0)