• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# This script retrieves the repository and branch details of a GitHub pull request
4
5# Assign command line arguments to variables
6# GH_TOKEN is the GitHub authentication token
7# PR_NUMBER is the number of the pull request
8# REPO_NAME is the name of the repository
9GH_TOKEN="$1"
10PR_NUMBER="$2"
11REPO_NAME="$3"
12
13PR_DETAILS=$(curl -s -H "Authorization: token $GH_TOKEN" "https://api.github.com/repos/$REPO_NAME/pulls/$PR_NUMBER")
14
15REPO_FULL_NAME=$(echo "$PR_DETAILS" | jq -r .head.repo.full_name)
16BRANCH_NAME=$(echo "$PR_DETAILS" | jq -r .head.ref)
17
18# Export vars to GITHUB_ENV so they can be used by later scripts
19echo "REPO_FULL_NAME=$REPO_FULL_NAME" >> "$GITHUB_ENV"
20echo "BRANCH_NAME=$BRANCH_NAME" >> "$GITHUB_ENV"
21