fix PR approved state (#134)

* fix PR approved state

* fix topological sort wf
This commit is contained in:
Sarthak Agarwal 2025-04-10 21:07:38 +05:30 committed by GitHub
parent 1fc1ccf9af
commit 6b71c6052d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 120 additions and 68 deletions

View file

@ -29,18 +29,25 @@ jobs:
fetch-depth: 0
- name: Validate PR
run: |
# Checking for any workflow changes for security risks
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
echo "Workflow changes detected."
# Check for any workflow changes
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
echo "⚠️ Workflow changes detected."
# Check if the PR author is allowed
# Get the PR author
AUTHOR="${{ github.event.pull_request.user.login }}"
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
echo "PR Author: $AUTHOR"
# Allowlist check
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
echo "✅ Authorized user ($AUTHOR). Proceeding."
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
else
echo "Authorized user ($AUTHOR). Proceeding."
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
fi
else
echo "✅ No workflow file changes detected. Proceeding."
fi
- name: 🐍 Set up Python 3.11 for CLI

View file

@ -24,18 +24,25 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Validate PR
run: |
# Checking for any workflow changes for security risks
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
echo "Workflow changes detected."
# Check for any workflow changes
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
echo "⚠️ Workflow changes detected."
# Check if the PR author is allowed
# Get the PR author
AUTHOR="${{ github.event.pull_request.user.login }}"
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
echo "PR Author: $AUTHOR"
# Allowlist check
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
echo "✅ Authorized user ($AUTHOR). Proceeding."
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
else
echo "Authorized user ($AUTHOR). Proceeding."
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
fi
else
echo "✅ No workflow file changes detected. Proceeding."
fi
- name: Set up Python 3.11 for CLI

View file

@ -24,18 +24,25 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Validate PR
run: |
# Checking for any workflow changes for security risks
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
echo "Workflow changes detected."
# Check for any workflow changes
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
echo "⚠️ Workflow changes detected."
# Check if the PR author is allowed
# Get the PR author
AUTHOR="${{ github.event.pull_request.user.login }}"
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
echo "PR Author: $AUTHOR"
# Allowlist check
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
echo "✅ Authorized user ($AUTHOR). Proceeding."
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
else
echo "Authorized user ($AUTHOR). Proceeding."
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
fi
else
echo "✅ No workflow file changes detected. Proceeding."
fi
- name: Set up Python 3.11 for CLI

View file

@ -22,18 +22,25 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Validate PR
run: |
# Checking for any workflow changes for security risks
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
echo "Workflow changes detected."
# Check for any workflow changes
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
echo "⚠️ Workflow changes detected."
# Check if the PR author is allowed
# Get the PR author
AUTHOR="${{ github.event.pull_request.user.login }}"
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
echo "PR Author: $AUTHOR"
# Allowlist check
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
echo "✅ Authorized user ($AUTHOR). Proceeding."
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
else
echo "Authorized user ($AUTHOR). Proceeding."
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
fi
else
echo "✅ No workflow file changes detected. Proceeding."
fi
- name: Set up Python 3.11 for CLI

View file

@ -24,18 +24,25 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Validate PR
run: |
# Checking for any workflow changes for security risks
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
echo "Workflow changes detected."
# Check for any workflow changes
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
echo "⚠️ Workflow changes detected."
# Check if the PR author is allowed
# Get the PR author
AUTHOR="${{ github.event.pull_request.user.login }}"
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
echo "PR Author: $AUTHOR"
# Allowlist check
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
echo "✅ Authorized user ($AUTHOR). Proceeding."
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
else
echo "Authorized user ($AUTHOR). Proceeding."
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
fi
else
echo "✅ No workflow file changes detected. Proceeding."
fi
- name: Set up Python 3.11 for CLI

View file

@ -24,18 +24,25 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Validate PR
run: |
# Checking for any workflow changes for security risks
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
echo "Workflow changes detected."
# Check for any workflow changes
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
echo "⚠️ Workflow changes detected."
# Check if the PR author is allowed
# Get the PR author
AUTHOR="${{ github.event.pull_request.user.login }}"
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
echo "PR Author: $AUTHOR"
# Allowlist check
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
echo "✅ Authorized user ($AUTHOR). Proceeding."
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
else
echo "Authorized user ($AUTHOR). Proceeding."
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
fi
else
echo "✅ No workflow file changes detected. Proceeding."
fi
- name: Set up Python 3.11 for CLI

View file

@ -24,18 +24,25 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Validate PR
run: |
# Checking for any workflow changes for security risks
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
echo "Workflow changes detected."
# Check for any workflow changes
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
echo "⚠️ Workflow changes detected."
# Check if the PR author is allowed
# Get the PR author
AUTHOR="${{ github.event.pull_request.user.login }}"
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
echo "PR Author: $AUTHOR"
# Allowlist check
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
echo "✅ Authorized user ($AUTHOR). Proceeding."
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
else
echo "Authorized user ($AUTHOR). Proceeding."
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
fi
else
echo "✅ No workflow file changes detected. Proceeding."
fi

View file

@ -22,23 +22,26 @@ jobs:
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Validate PR
run: |
# Checking for any workflow changes for security risks
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
echo "Workflow changes detected."
# Check if the PR author is allowed
# Check for any workflow changes
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
echo "⚠️ Workflow changes detected."
# Get the PR author
AUTHOR="${{ github.event.pull_request.user.login }}"
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
echo "PR Author: $AUTHOR"
# Allowlist check
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
echo "✅ Authorized user ($AUTHOR). Proceeding."
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
else
echo "Authorized user ($AUTHOR). Proceeding."
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
fi
fiif git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "end-to-end-topological-sort-test.yaml"; then
echo "This workflow file has been modified. Exiting for security."
exit 1
else
echo "✅ No workflow file changes detected. Proceeding."
fi
- name: Set up Python 3.11 for CLI