Skip to content

Commit

Permalink
Add debugging info to action
Browse files Browse the repository at this point in the history
  • Loading branch information
evankanderson committed Oct 29, 2024
1 parent 16bc31f commit f232262
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/update.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Update
on:
pull_request:
branches: [main]

jobs:
ruletype-update:
Expand All @@ -9,6 +10,8 @@ jobs:
steps:
- name: Checkout current
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: ${{github.event_name == 'pull_request' && 2 || 0}}

- name: Checkout comparison branch (main) in subdirectory
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
Expand All @@ -27,13 +30,20 @@ jobs:
# Fail the script if any command fails
set -e
git branch -a
# Determine the current branch and compare branch (default to 'main')
GITHUB_BRANCH=${GITHUB_REF##*/}
GITHUB_BRANCH=remotes/${GITHUB_REF#*/}
COMPARE_BRANCH="main"
git diff --name-only -r HEAD^1 HEAD
git log
# Show changed files between the current branch and the comparison branch
echo "Comparing $GITHUB_BRANCH with $COMPARE_BRANCH..."
CHANGED_FILES=$(git diff --name-only origin/$COMPARE_BRANCH...$GITHUB_BRANCH)
# See https://stackoverflow.com/a/74268200 for why diffing with HEAD^1 is used
echo "Comparing $GITHUB_BRANCH (from '$GITHUB_REF') with $COMPARE_BRANCH..."
CHANGED_FILES=$(git diff --name-only "origin/$COMPARE_BRANCH" "$GITHUB_BRANCH")
echo ----
echo $CHANGED_FILES
if [ -z "$CHANGED_FILES" ]; then
echo "No changes found."
Expand All @@ -49,6 +59,8 @@ jobs:
run: |
# Fail the script if any command fails
set -e
go build -o ./mindev github.com/mindersec/minder/cmd/dev@latest
# Loop through the changed files and run the go command for each
for FILE in ${{ env.changed_files }}; do
Expand All @@ -61,7 +73,7 @@ jobs:
if [ -f "$BEFORE_FILE" ]; then
echo "Running ruletype validate-update command for $BEFORE_FILE and $AFTER_FILE..."
# Run the go command with the before and after files
go run github.com/mindersec/minder/cmd/dev@latest ruletype validate-update --before "$BEFORE_FILE" --after "$AFTER_FILE"
./mindev ruletype validate-update --before "$BEFORE_FILE" --after "$AFTER_FILE"
else
echo "Warning: $BEFORE_FILE does not exist, skipping."
fi
Expand Down

0 comments on commit f232262

Please sign in to comment.