From 67207edb4cb18362d538a44481c10600da66ba34 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Mon, 18 Oct 2021 11:40:01 +0200 Subject: [PATCH] only assume it's an initial run if the version already exists --- .github/workflows/release-check.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-check.yml b/.github/workflows/release-check.yml index 95260bb4..5f57508c 100644 --- a/.github/workflows/release-check.yml +++ b/.github/workflows/release-check.yml @@ -19,11 +19,17 @@ jobs: - name: Determine version run: echo "VERSION=$(jq -r .version version.json)" >> $GITHUB_ENV - name: Check if this is the initial deployment - # if this is the initial deployment of this workflow, we don't need to run any checks + # This is the initial run (deploying the version.json to this repo) if + # 1. version.json didn't exist before, AND + # 2. there doesn't exist a git tag for the version (as read from version.json) + # In that case, we don't need to run the rest of the workflow. run: | git fetch origin ${{ github.event.pull_request.base.sha }} + git fetch origin --tags read -ra arr <<< $(git diff-index ${{ github.event.pull_request.base.sha }} -- version.json) - if [[ "${arr[4]}" == "A" ]]; then + git rev-list ${{ env.VERSION }} &> /dev/null + status=$? + if [[ "${arr[4]}" == "A" && $status == 0 ]]; then echo "INITIAL_RUN=true" >> $GITHUB_ENV fi - name: Install semver (node command line tool)