Skip to content

Commit

Permalink
updated logic after CR - TEST
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadav Ben Ami authored and Nadav Ben Ami committed Oct 22, 2024
1 parent 4cd087b commit 7525a5c
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions .github/workflows/test-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ jobs:
echo "Repository Name: ${{ github.repository }}"
# Check out the branch from the pull request, whether it's from a fork or not
- name: Checkout the pull request's branch
- name: Checkout the target branch # logic step
run: |
set -ex
# debug
echo "==== before"
git status
if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then
echo "We're in pull_request_target"
target_branch="${{ github.event.pull_request.base.ref }}" # from old config
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "PR from a fork detected. Checking out the fork's branch."
git remote add fork https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
Expand All @@ -58,9 +60,12 @@ jobs:
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
# `actions/checkout` will checkout to the branch that you chose in the `dispatch` tab - so we do nothing
echo "we're in the right branch. no need to checkout (dispatch)"
target_branch="${{ github.ref_name }}" # from old config
echo $target_branch # from old config
elif [[ "${{ github.event_name }}" == "push" ]]; then
# we believe that `actions/checkout` will checkout to the branch that we push into (i.e. either `dev` or `main`)
echo "we're in the right branch. no need to checkout (push)"
target_branch="$(gh pr view --json baseRefName,headRefName --jq .baseRefName)" # from old config
else
echo "we're not in push/pull/dispatch. error."
exit 1
Expand All @@ -80,19 +85,6 @@ jobs:
- name: Set environment based on target branch
run: |
set -ex
if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then
# Use the target branch of the pull request
echo "We're in pull_request_target"
target_branch="${{ github.event.pull_request.base.ref }}"
elif [[ "${{ github.event_name }}" == "push" ]]; then
echo "We're in push"
target_branch="$(gh pr view --json baseRefName,headRefName --jq .baseRefName)"
else
# Use the branch of the push event
target_branch="${{ github.ref_name }}"
echo $target_branch
fi
if [[ "$target_branch" == "main" ]]; then
echo "Running on prod environment."
Expand Down Expand Up @@ -127,7 +119,7 @@ jobs:
run: |
echo "Changed notebook files: ${{ steps.changed-files-ipynb.outputs.all_changed_files }}"
- name: Set changed notebook into environment variables
- name: Set changed notebook into environment variables # Could be integrated in logic step
run: |
set -ex
if [ "${{ github.event_name }}" == 'pull_request_target' ]; then
Expand Down

0 comments on commit 7525a5c

Please sign in to comment.