From a15acb3ccb9a8c1f6658365379e49ae3a3c1c952 Mon Sep 17 00:00:00 2001 From: Francesco Pira Date: Mon, 6 May 2024 15:33:50 +0200 Subject: [PATCH] additional pr wf checks --- .github/workflows/pr.yml | 13 +++++++++++++ test.docker.sh | 11 ++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7c3e6eb..a96b9d7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -18,6 +18,8 @@ jobs: steps: - name: Clone repo uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set .nvmrc content to stage output id: nvmrc @@ -32,6 +34,17 @@ jobs: - name: Install dependencies run: npm ci + - name: Check git tag for version + run: | + PACKAGE_VERSION=$(node -p "require('./package.json').version") + echo "Current version in package.json: $PACKAGE_VERSION" + if git rev-parse "${PACKAGE_VERSION}" >/dev/null 2>&1; then + echo "Error: git tag ${PACKAGE_VERSION} already exists." + exit 1 + else + echo "Good: no matching git tag exists for version ${PACKAGE_VERSION}" + fi + - name: Run tests run: npm run test env: diff --git a/test.docker.sh b/test.docker.sh index 88b7a66..932d86c 100755 --- a/test.docker.sh +++ b/test.docker.sh @@ -21,7 +21,16 @@ docker run --rm \ github-graphql-client:latest "-v" # commands below need GITHUB_TOKEN to be set. -source .env.sh +if [[ -f .env.sh ]]; then + echo "Sourcing .env.sh file" + source .env.sh +elif [[ ! -z "$GITHUB_TOKEN" ]]; then + echo "No .env.sh file set, reading GITHUB_TOKEN from environment" + exit 1 +else + echo "GITHUB_TOKEN not set and .env.sh does not exist. Exiting..." + exit 1 +fi echo "************ branch arg missing *******************"