Skip to content

Commit

Permalink
feat: check-diff.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed Mar 21, 2024
1 parent 3a1a787 commit ba24563
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions scripts/check-diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash

set -euo pipefail -o nounset

# If the script is run with RUNNER_DEBUG=1, print all statements executed
if [[ "${RUNNER_DEBUG:-}" == "1" ]]; then
set -x
fi

language="$(jq -r '.github.languages | .[0]' <<< "$CONTEXT")"

default_branch="$(jq -r '.github.default_branch' <<< "$CONTEXT")"

pushd "$TARGET" > /dev/null

actual="$(git diff "origin/$default_branch" | grep '^[+-]')"
expected=""

if [[ "$language" == "Go" ]]; then
expected='--- a/.github/workflows/go-check.yml
+++ b/.github/workflows/go-check.yml
- uses: pl-strflt/uci/.github/workflows/[email protected]
+ uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
--- a/.github/workflows/go-test.yml
+++ b/.github/workflows/go-test.yml
- uses: pl-strflt/uci/.github/workflows/[email protected]
+ uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
+ secrets:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
--- a/.github/workflows/release-check.yml
+++ b/.github/workflows/release-check.yml
- uses: pl-strflt/uci/.github/workflows/[email protected]
+ uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
--- a/.github/workflows/releaser.yml
+++ b/.github/workflows/releaser.yml
- uses: pl-strflt/uci/.github/workflows/[email protected]
+ uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
--- a/.github/workflows/tagpush.yml
+++ b/.github/workflows/tagpush.yml
- uses: pl-strflt/uci/.github/workflows/[email protected]
+ uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]'
elif [[ "$language" == "JavaScript" ]]; then
expected='--- a/.github/workflows/js-test-and-release.yml
+++ b/.github/workflows/js-test-and-release.yml
+ id-token: write
+ pull-requests: write
- uses: pl-strflt/uci/.github/workflows/[email protected]
+ uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}'
else
echo "Unknown language: $language"
exit 1
fi

if [[ "$actual" == "$expected" ]]; then
echo "No diff found"
exit 0
else
echo "Diff found"
echo "$actual"
echo "---"
echo "$expected"
exit 1
fi

0 comments on commit ba24563

Please sign in to comment.