From e34707b74cfc4e28f5a2ee8201aecb6f3e1aab42 Mon Sep 17 00:00:00 2001 From: Arkadik94 Date: Mon, 6 Nov 2023 21:11:37 +0200 Subject: [PATCH 1/2] Put the shell code in separate file, for not reusing code --- .github/workflows/clean_tree.yaml | 27 +++---------------- github-actions-scripts-sh/clean-tree-check.sh | 7 +++++ 2 files changed, 10 insertions(+), 24 deletions(-) create mode 100644 github-actions-scripts-sh/clean-tree-check.sh diff --git a/.github/workflows/clean_tree.yaml b/.github/workflows/clean_tree.yaml index aebe8fcc..51e90bdb 100644 --- a/.github/workflows/clean_tree.yaml +++ b/.github/workflows/clean_tree.yaml @@ -14,36 +14,15 @@ jobs: - name: make sure package.lock does not exist run: rm -f package-lock.json - name: Check Tree if package-lock.json file was existing and removed - run: | - if [[ -n $(git status -s) ]]; then - echo "ERROR: tree is dirty after removing package-lock.json file" - git status - exit 1 - else - echo "Working tree is clean." - fi + run: bash ${GITHUB_WORKSPACE}/github-actions-scripts-sh/clean-tree-check.sh "removing package-lock.json file" - name: Install dependencies run: yarn - name: Check Tree after yarn - run: | - if [[ -n $(git status -s) ]]; then - echo "ERROR: tree is dirty after yarn" - git status - exit 1 - else - echo "Working tree is clean." - fi + run: bash ${GITHUB_WORKSPACE}/github-actions-scripts-sh/clean-tree-check.sh "yarn" - name: Build run: yarn build - name: Check Tree after build - run: | - if [[ -n $(git status -s) ]]; then - echo "ERROR: tree is dirty after yarn build" - git status - exit 1 - else - echo "Working tree is clean." - fi + run: bash ${GITHUB_WORKSPACE}/github-actions-scripts-sh/clean-tree-check.sh "yarn build" - name: Clean up if: always() run: npm uninstall -g yarn \ No newline at end of file diff --git a/github-actions-scripts-sh/clean-tree-check.sh b/github-actions-scripts-sh/clean-tree-check.sh new file mode 100644 index 00000000..f185626a --- /dev/null +++ b/github-actions-scripts-sh/clean-tree-check.sh @@ -0,0 +1,7 @@ +if [[ -n $(git status -s) ]]; then + echo "ERROR: tree is dirty after $1" + git status + exit 1 +else + echo "Working tree is clean." +fi \ No newline at end of file From 5734acd407059f0e539f7f6224c03a4e7467c83d Mon Sep 17 00:00:00 2001 From: Arkadik94 Date: Fri, 10 Nov 2023 19:03:50 +0200 Subject: [PATCH 2/2] Change to Custom GitHub Action --- .github/workflows/clean_tree.yaml | 18 ++++++++++++------ github-actions-scripts-sh/clean-tree-check.sh | 7 ------- 2 files changed, 12 insertions(+), 13 deletions(-) delete mode 100644 github-actions-scripts-sh/clean-tree-check.sh diff --git a/.github/workflows/clean_tree.yaml b/.github/workflows/clean_tree.yaml index 51e90bdb..5eb59036 100644 --- a/.github/workflows/clean_tree.yaml +++ b/.github/workflows/clean_tree.yaml @@ -13,16 +13,22 @@ jobs: run: npm install -g yarn - name: make sure package.lock does not exist run: rm -f package-lock.json - - name: Check Tree if package-lock.json file was existing and removed - run: bash ${GITHUB_WORKSPACE}/github-actions-scripts-sh/clean-tree-check.sh "removing package-lock.json file" + - name: Git Check Clean Tree + uses: ArkadiK94/action-git-clean-tree@v1.0.3 + with: + error-reason: "removing package-lock.json file" - name: Install dependencies run: yarn - - name: Check Tree after yarn - run: bash ${GITHUB_WORKSPACE}/github-actions-scripts-sh/clean-tree-check.sh "yarn" + - name: Git Check Clean Tree + uses: ArkadiK94/action-git-clean-tree@v1.0.3 + with: + error-reason: "yarn" - name: Build run: yarn build - - name: Check Tree after build - run: bash ${GITHUB_WORKSPACE}/github-actions-scripts-sh/clean-tree-check.sh "yarn build" + - name: Git Check Clean Tree + uses: ArkadiK94/action-git-clean-tree@v1.0.3 + with: + error-reason: "yarn build" - name: Clean up if: always() run: npm uninstall -g yarn \ No newline at end of file diff --git a/github-actions-scripts-sh/clean-tree-check.sh b/github-actions-scripts-sh/clean-tree-check.sh deleted file mode 100644 index f185626a..00000000 --- a/github-actions-scripts-sh/clean-tree-check.sh +++ /dev/null @@ -1,7 +0,0 @@ -if [[ -n $(git status -s) ]]; then - echo "ERROR: tree is dirty after $1" - git status - exit 1 -else - echo "Working tree is clean." -fi \ No newline at end of file