Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
mfaizanse committed Jan 18, 2024
1 parent 01151f3 commit 78deb19
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ jobs:
GH_TOKEN: ${{ github.token }}
PR_URL: https://github.com/kyma-project/eventing-manager/pull/${{ github.event.number }}
run: |
echo "PR: ${PR_URL}"
gh pr view ${PR_URL} --json=reviewDecision
./scripts/is_pr_approved.sh
- name: Wait for the 'pull-eventing-manager-build' job to succeed
id: pull-wait-build
Expand Down
24 changes: 24 additions & 0 deletions scripts/is_pr_approved.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

# This script will check if a PR is approved or not.
# Usage: To run this script, provide the following environment variable(s) and run this script.
# - PR_URL - (example: https://github.com/kyma-project/eventing-manager/pull/123)

# standard bash error handling
set -o nounset # treat unset variables as an error and exit immediately.
set -E # needs to be set if we want the ERR trap.
set -o pipefail # prevents errors in a pipeline from being masked.
set -o errexit # exit immediately when a command fails.

## MAIN Logic
echo "Checking approval status of : ${PR_URL}"
REVIEW_DECISION=$(gh pr view ${PR_URL} --json=reviewDecision | jq -r '.reviewDecision')

echo "REVIEW_DECISION: ${REVIEW_DECISION}"
if [[ ${REVIEW_DECISION} == "APPROVED" ]]; then
echo "Pull request is approved!"
exit 0
fi

echo "Error: Pull request is not approved!"
exit 1

0 comments on commit 78deb19

Please sign in to comment.