Skip to content

Commit

Permalink
chore: configurable owner
Browse files Browse the repository at this point in the history
  • Loading branch information
paulredmond committed Nov 8, 2023
1 parent 6fea63a commit 8db6eed
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions .github/workflows/calculate-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
description: The branch name
required: true
type: string
owner:
description: The GitHub owner of the repository
required: false
type: string
default: encodium
repo:
description: The GitHub repository name
required: true
Expand All @@ -29,29 +34,30 @@ jobs:
GH_TOKEN: ${{ secrets.github_token }}
run: |
requested_branch="${{ inputs.branch }}"
owner="${{ inputs.owner }}"
repo="${{ inputs.repo }}"
branch_name=
found=
echo "Checking to see if the branch \"${requested_branch}\" exists in this project."
branch_info=$(gh api "/repos/${owner}/${repo}/branches/${requested_branch}" --jq '{name: .name, sha: .commit.sha}')
branch_info=$(gh api "/repos/encodium/${repo}/branches/$requested_branch" --jq '{name: .name, sha: .commit.sha}')
branch_name_candidate=$(echo "$branch_info" | jq -r '.name')
sha=$(echo "$branch_info" | jq -r '.sha')
sha_short=$(echo "$branch_info" | jq -r '.sha[:7]')
branch_name_candidate=$(echo "${branch_info}" | jq -r '.name')
sha=$(echo "${branch_info}" | jq -r '.sha')
sha_short=$(echo "${branch_info}" | jq -r '.sha[:7]')
echo "Branch name from response: ${branch_name_candidate}"
echo "SHA from response: ${sha}"
echo "SHA (short) from response: ${sha_short}"
if [[ "$branch_name_candidate" == "$requested_branch" ]];
if [[ "${branch_name_candidate}" == "${requested_branch}" ]];
then
echo "Branch \"${branch_name_candidate}\" found."
branch_name="$branch_name_candidate"
branch_name="${branch_name_candidate}"
found=true
fi
echo "branch=$branch_name" >> "$GITHUB_OUTPUT"
echo "found=$found" >> "$GITHUB_OUTPUT"
echo "sha=$sha" >> "$GITHUB_OUTPUT"
echo "sha_short=$sha_short" >> "$GITHUB_OUTPUT"
echo "branch=${branch_name}" >> "$GITHUB_OUTPUT"
echo "found=${found}" >> "$GITHUB_OUTPUT"
echo "sha=${sha}" >> "$GITHUB_OUTPUT"
echo "sha_short=${sha_short}" >> "$GITHUB_OUTPUT"

0 comments on commit 8db6eed

Please sign in to comment.