Skip to content
Open

test1 #249

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/gobo_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Format Code

on:
pull_request:
types:
- opened
- edited
- ready_for_review
- synchronize

jobs:
format:
runs-on: ubuntu-latest # Or 'windows-latest' if using Windows runner

steps:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Download Release
run: |
curl -LO https://github.com/Pizzaandy/Gobo/releases/download/v0.4.0/gobo-ubuntu.zip

- name: Extract ZIP
run: |
unzip gobo-ubuntu.zip

- name: Ensure executable permissions
run: |
chmod +x ./gobo

- name: Get Changed Files
id: changed_files
run: |
target_branch="${{ github.event.pull_request.base.ref }}"
pr_branch="${{ github.event.pull_request.head.ref }}"
Comment on lines +31 to +35
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Potential Security Risk in Branch Reference, nyan!
The use of ${{ github.event.pull_request.head.ref }} on line 35 is potentially untrusted per security guidelines. It is recommended to sanitize this input or pass it through an environment variable as advised by GitHub’s security hardening guides, nyan!

🧰 Tools
🪛 actionlint (1.7.4)

33-33: "github.event.pull_request.head.ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions for more details

(expression)

echo "Target branch is $target_branch"
echo "PR branch is $pr_branch"

# Fetch the base branch and PR branch commit refs
git fetch origin $target_branch:$target_branch
git fetch origin $pr_branch:$pr_branch

# Store the result of the diff in the environment variable
changed_files=$(git diff --name-only origin/$target_branch...origin/$pr_branch)
echo "changed_files=$changed_files" >> $GITHUB_ENV

# Echo the contents of the changed_files variable

- name: Run Formatter on Changed Files
run: |
if [ -n "$changed_files" ]; then
# Iterate over each file using a for loop
for file in $changed_files; do
echo "Formatting $file"
./gobo "$file" # Run formatter on each changed file
done
else
echo "No files changed, skipping formatting."
fi

- name: Clean up Gobo Files
run: |
rm -rf gobo-ubuntu.zip gobo

- name: Check for formatting changes
run: |
git diff --quiet --exit-code || exit 1