From e338a630e679fac7089c57b02995c9e8942a19e6 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Fri, 19 Feb 2021 00:49:16 -0500 Subject: [PATCH 01/25] Tag entrypoint as a bash script This script uses bashisms --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 023e697..df967f4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # e is for exiting the script automatically if a command fails, u is for exiting if a variable is not set # x would be for showing the commands before they are executed set -eu From 7326fa4da43356c2b1d4d4bc0714fcee6652e407 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Fri, 19 Feb 2021 00:49:40 -0500 Subject: [PATCH 02/25] Switch to composite --- action.yml | 18 ++++++++++++++++-- entrypoint.sh | 15 ++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index a0d155c..7fa1af2 100644 --- a/action.yml +++ b/action.yml @@ -41,8 +41,22 @@ inputs: default: '' runs: - using: 'docker' - image: 'Dockerfile' + using: 'composite' + steps: + - name: prettier + shell: bash + run: >- + PATH=$(cd $GITHUB_ACTION_PATH; npm bin):$PATH + INPUT_COMMIT_MESSAGE="${{ inputs.commit_message }}" + INPUT_COMMIT_OPTIONS="${{ inputs.commit_options }}" + INPUT_DRY="${{ inputs.dry }}" + INPUT_FILE_PATTERN="${{ inputs.file_pattern }}" + INPUT_ONLY_CHANGED="${{ inputs.only_changed }}" + INPUT_PRETTIER_OPTIONS="${{ inputs.prettier_options }}" + INPUT_PRETTIER_PLUGINS="${{ inputs.prettier_plugins }}" + INPUT_PRETTIER_VERSION="${{ inputs.prettier_version }}" + INPUT_SAME_COMMIT="${{ inputs.same_commit }}" + $GITHUB_ACTION_PATH/entrypoint.sh branding: icon: 'award' diff --git a/entrypoint.sh b/entrypoint.sh index df967f4..9a3812a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -25,14 +25,22 @@ _git_changed() { [[ -n "$(git status -s)" ]] } +( +if [ -n "$GITHUB_ACTION_PATH" ]; then + cd $GITHUB_ACTION_PATH + maybe_global='' +else + maybe_global=--global +fi + # PROGRAM echo "Installing prettier..." case $INPUT_PRETTIER_VERSION in false) - npm install --silent --global prettier + npm install --silent $maybe_global prettier ;; *) - npm install --silent --global prettier@$INPUT_PRETTIER_VERSION + npm install --silent $maybe_global prettier@$INPUT_PRETTIER_VERSION ;; esac @@ -46,8 +54,9 @@ if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then exit 1 fi done - npm install --silent --global $INPUT_PRETTIER_PLUGINS + npm install --silent $maybe_global $INPUT_PRETTIER_PLUGINS fi +) echo "Prettifing files..." echo "Files:" From 8a68c5b4d367a45b57eef4580cff1f058fefcf07 Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 17:45:52 +0100 Subject: [PATCH 03/25] Experimenting with a simpler form of composite actions --- action.yml | 29 +++++++++-------------------- entrypoint.sh | 4 ++-- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/action.yml b/action.yml index 7fa1af2..988fdf6 100644 --- a/action.yml +++ b/action.yml @@ -7,7 +7,7 @@ inputs: commit_message: description: Commit message, will be ignored if used with same_commit required: false - default: 'Prettified Code!' + default: "Prettified Code!" same_commit: description: Update the current commit instead of creating a new one required: false @@ -18,11 +18,11 @@ inputs: file_pattern: description: File pattern used for `git add`, can't be used with only_changed! required: false - default: '*' + default: "*" prettier_options: description: Options for the `prettier` command required: false - default: '--write **/*.js' + default: "--write **/*.js" dry: description: Running the script in dry mode just shows whether there are files that should be prettified or not required: false @@ -38,26 +38,15 @@ inputs: prettier_plugins: description: Install Prettier plugins, i.e. `@prettier/prettier-php @prettier/some-other-plugin` required: false - default: '' + default: "" runs: - using: 'composite' + using: "composite" steps: - - name: prettier + - name: Prettify code! shell: bash - run: >- - PATH=$(cd $GITHUB_ACTION_PATH; npm bin):$PATH - INPUT_COMMIT_MESSAGE="${{ inputs.commit_message }}" - INPUT_COMMIT_OPTIONS="${{ inputs.commit_options }}" - INPUT_DRY="${{ inputs.dry }}" - INPUT_FILE_PATTERN="${{ inputs.file_pattern }}" - INPUT_ONLY_CHANGED="${{ inputs.only_changed }}" - INPUT_PRETTIER_OPTIONS="${{ inputs.prettier_options }}" - INPUT_PRETTIER_PLUGINS="${{ inputs.prettier_plugins }}" - INPUT_PRETTIER_VERSION="${{ inputs.prettier_version }}" - INPUT_SAME_COMMIT="${{ inputs.same_commit }}" - $GITHUB_ACTION_PATH/entrypoint.sh + run: ${{ github.action_path }}/entrypoint.sh branding: - icon: 'award' - color: 'green' + icon: "award" + color: "green" diff --git a/entrypoint.sh b/entrypoint.sh index 9a3812a..afc91d6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -37,10 +37,10 @@ fi echo "Installing prettier..." case $INPUT_PRETTIER_VERSION in false) - npm install --silent $maybe_global prettier + npm install --silent -g prettier ;; *) - npm install --silent $maybe_global prettier@$INPUT_PRETTIER_VERSION + npm install --silent -g prettier@$INPUT_PRETTIER_VERSION ;; esac From 3aa6d7608dfc60b75f92b937f82af1650f29ca3a Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 17:54:00 +0100 Subject: [PATCH 04/25] Added testing variable --- entrypoint.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index afc91d6..1b6ef8c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -26,12 +26,8 @@ _git_changed() { } ( -if [ -n "$GITHUB_ACTION_PATH" ]; then - cd $GITHUB_ACTION_PATH - maybe_global='' -else - maybe_global=--global -fi + +echo ${{ inputs.prettier_options }} # PROGRAM echo "Installing prettier..." From 5f9fa33c3d44a904b690f93f53648263779c1997 Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 17:58:30 +0100 Subject: [PATCH 05/25] Fixed variable problem --- action.yml | 10 ++++++++++ entrypoint.sh | 2 -- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 988fdf6..b23b101 100644 --- a/action.yml +++ b/action.yml @@ -46,6 +46,16 @@ runs: - name: Prettify code! shell: bash run: ${{ github.action_path }}/entrypoint.sh + env: + INPUT_COMMIT_MESSAGE: ${{ inputs.commit_message }} + INPUT_SAME_COMMIT: ${{ inputs.same_commit }} + INPUT_COMMIT_OPTIONS: ${{ inputs.commit_options }} + INPUT_FILE_PATTERN: ${{ inputs.file_pattern }} + INPUT_PRETTIER_OPTIONS: ${{ inputs.prettier_options }} + INPUT_DRY: ${{ inputs.dry }} + INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }} + INPUT_ONLY_CHANGED: ${{ inputs.only_changed }} + INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }} branding: icon: "award" diff --git a/entrypoint.sh b/entrypoint.sh index 1b6ef8c..f5dcad8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -27,8 +27,6 @@ _git_changed() { ( -echo ${{ inputs.prettier_options }} - # PROGRAM echo "Installing prettier..." case $INPUT_PRETTIER_VERSION in From b5409d48a9aed968ed3fa12eeb5bd80fffbc328c Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:02:12 +0100 Subject: [PATCH 06/25] Removed global option for testing --- entrypoint.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index f5dcad8..a463036 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -31,10 +31,10 @@ _git_changed() { echo "Installing prettier..." case $INPUT_PRETTIER_VERSION in false) - npm install --silent -g prettier + npm install --silent prettier ;; *) - npm install --silent -g prettier@$INPUT_PRETTIER_VERSION + npm install --silent prettier@$INPUT_PRETTIER_VERSION ;; esac @@ -48,7 +48,7 @@ if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then exit 1 fi done - npm install --silent $maybe_global $INPUT_PRETTIER_PLUGINS + npm install --silent $INPUT_PRETTIER_PLUGINS fi ) From 5c365ab3fa00072450bddc018c60fc181d133e6d Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:10:42 +0100 Subject: [PATCH 07/25] Another bugfix attempt trying to generate the global flag only if needed --- Dockerfile | 4 ---- action.yml | 1 + entrypoint.sh | 14 +++++++++----- 3 files changed, 10 insertions(+), 9 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index cfd542a..0000000 --- a/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM node:lts-alpine3.9 -RUN apk update && apk add --no-cache bash git openssh -COPY entrypoint.sh /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml index b23b101..3a70533 100644 --- a/action.yml +++ b/action.yml @@ -56,6 +56,7 @@ runs: INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }} INPUT_ONLY_CHANGED: ${{ inputs.only_changed }} INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }} + PATH: $(cd $GITHUB_ACTION_PATH; npm bin):$PATH branding: icon: "award" diff --git a/entrypoint.sh b/entrypoint.sh index a463036..a5b1b55 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash # e is for exiting the script automatically if a command fails, u is for exiting if a variable is not set # x would be for showing the commands before they are executed -set -eu +set -eux # FUNCTIONS # Function for setting up git env in the docker container (copied from https://github.com/stefanzweifel/git-auto-commit-action/blob/master/entrypoint.sh) @@ -25,16 +25,20 @@ _git_changed() { [[ -n "$(git status -s)" ]] } -( +if [ -n "$GITHUB_ACTION_PATH" ]; then + INPUT_IS_GLOBAL='' +else + INPUT_IS_GLOBAL=--global +fi # PROGRAM echo "Installing prettier..." case $INPUT_PRETTIER_VERSION in false) - npm install --silent prettier + npm install --silent $INPUT_IS_GLOBAL prettier ;; *) - npm install --silent prettier@$INPUT_PRETTIER_VERSION + npm install --silent $INPUT_IS_GLOBAL prettier@$INPUT_PRETTIER_VERSION ;; esac @@ -48,7 +52,7 @@ if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then exit 1 fi done - npm install --silent $INPUT_PRETTIER_PLUGINS + npm install --silent $INPUT_IS_GLOBAL $INPUT_PRETTIER_PLUGINS fi ) From 4d25f0bd7c27dc7997a445df40a4fcb24178ad4e Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:13:22 +0100 Subject: [PATCH 08/25] Moving the path to the run part of the yml --- action.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 3a70533..ebe05a8 100644 --- a/action.yml +++ b/action.yml @@ -45,7 +45,9 @@ runs: steps: - name: Prettify code! shell: bash - run: ${{ github.action_path }}/entrypoint.sh + run: >- + PATH=$(cd $GITHUB_ACTION_PATH; npm bin):$PATH + ${{ github.action_path }}/entrypoint.sh env: INPUT_COMMIT_MESSAGE: ${{ inputs.commit_message }} INPUT_SAME_COMMIT: ${{ inputs.same_commit }} @@ -56,7 +58,6 @@ runs: INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }} INPUT_ONLY_CHANGED: ${{ inputs.only_changed }} INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }} - PATH: $(cd $GITHUB_ACTION_PATH; npm bin):$PATH branding: icon: "award" From 857bc257e2c663554e254924e3d851b80edbd84b Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:15:37 +0100 Subject: [PATCH 09/25] Added missing bracket --- entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/entrypoint.sh b/entrypoint.sh index a5b1b55..593a26b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -25,6 +25,7 @@ _git_changed() { [[ -n "$(git status -s)" ]] } +( if [ -n "$GITHUB_ACTION_PATH" ]; then INPUT_IS_GLOBAL='' else From 35d0d93afdf524b00ae09d73d99385e8a42228b2 Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:19:17 +0100 Subject: [PATCH 10/25] Removed global parameter --- entrypoint.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 593a26b..fc08fbe 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -26,20 +26,16 @@ _git_changed() { } ( -if [ -n "$GITHUB_ACTION_PATH" ]; then - INPUT_IS_GLOBAL='' -else - INPUT_IS_GLOBAL=--global -fi +cd "$GITHUB_ACTION_PATH" # PROGRAM echo "Installing prettier..." case $INPUT_PRETTIER_VERSION in false) - npm install --silent $INPUT_IS_GLOBAL prettier + npm install --silent prettier ;; *) - npm install --silent $INPUT_IS_GLOBAL prettier@$INPUT_PRETTIER_VERSION + npm install --silent prettier@$INPUT_PRETTIER_VERSION ;; esac @@ -53,7 +49,7 @@ if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then exit 1 fi done - npm install --silent $INPUT_IS_GLOBAL $INPUT_PRETTIER_PLUGINS + npm install --silent $INPUT_PRETTIER_PLUGINS fi ) From 01e9c566d8a487eed64fb1c27dee4790f880671f Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:31:20 +0100 Subject: [PATCH 11/25] Trying to exclude the useless package files --- entrypoint.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index fc08fbe..b10056d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash # e is for exiting the script automatically if a command fails, u is for exiting if a variable is not set # x would be for showing the commands before they are executed -set -eux +set -eu # FUNCTIONS # Function for setting up git env in the docker container (copied from https://github.com/stefanzweifel/git-auto-commit-action/blob/master/entrypoint.sh) @@ -26,9 +26,11 @@ _git_changed() { } ( -cd "$GITHUB_ACTION_PATH" # PROGRAM +# Changing to the directory +cd "$GITHUB_ACTION_PATH" + echo "Installing prettier..." case $INPUT_PRETTIER_VERSION in false) @@ -66,6 +68,13 @@ if _git_changed; then # Calling method to configure the git environemnt _git_setup + # Ignore node modules and other action created files + "/node_modules/ + package-lock.json + package.json + " >> .git/info/exclude + git update-index --assume-unchanged */node_modules/* package.json package-lock.json + if $INPUT_ONLY_CHANGED; then # --diff-filter=d excludes deleted files for file in $(git diff --name-only --diff-filter=d HEAD^..HEAD) From 3b82dd7e9544c7679a6cdbcc572c3867331dc5aa Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:36:38 +0100 Subject: [PATCH 12/25] Fixed missing command --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index b10056d..4e647d3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -69,7 +69,7 @@ if _git_changed; then _git_setup # Ignore node modules and other action created files - "/node_modules/ + echo "/node_modules/ package-lock.json package.json " >> .git/info/exclude From c5dd36440fbdebc6c7f06f73695788df401b3a72 Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:40:27 +0100 Subject: [PATCH 13/25] Updating the ignore mechanism --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 4e647d3..8765acb 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -69,11 +69,11 @@ if _git_changed; then _git_setup # Ignore node modules and other action created files - echo "/node_modules/ + echo "*/node_modules/* package-lock.json package.json " >> .git/info/exclude - git update-index --assume-unchanged */node_modules/* package.json package-lock.json + git update-index --assume-unchanged node_modules/ package.json package-lock.json if $INPUT_ONLY_CHANGED; then # --diff-filter=d excludes deleted files From 5564e3ef42cba75236e3f6b5d7946f911d006689 Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:41:32 +0100 Subject: [PATCH 14/25] Updating ignore mechanism 2 --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8765acb..0ae80e3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -73,7 +73,7 @@ if _git_changed; then package-lock.json package.json " >> .git/info/exclude - git update-index --assume-unchanged node_modules/ package.json package-lock.json + git update-index --assume-unchanged node_modules/ package-lock.json if $INPUT_ONLY_CHANGED; then # --diff-filter=d excludes deleted files From 77af3031890381afb940b22ac4f118a8c507b38b Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:44:35 +0100 Subject: [PATCH 15/25] Bugfixing ignore mechanism --- entrypoint.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 0ae80e3..ef53904 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -69,11 +69,9 @@ if _git_changed; then _git_setup # Ignore node modules and other action created files - echo "*/node_modules/* - package-lock.json - package.json - " >> .git/info/exclude - git update-index --assume-unchanged node_modules/ package-lock.json + git update-index --skip-worktree package.json + git update-index --skip-worktree node_modules/ + git update-index --skip-worktree package-lock.json if $INPUT_ONLY_CHANGED; then # --diff-filter=d excludes deleted files From 9acb5d89b9931334fba7886750dcaafe327b4e03 Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:47:01 +0100 Subject: [PATCH 16/25] Still debugging ignoring --- entrypoint.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index ef53904..0baf63f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -69,9 +69,10 @@ if _git_changed; then _git_setup # Ignore node modules and other action created files - git update-index --skip-worktree package.json - git update-index --skip-worktree node_modules/ - git update-index --skip-worktree package-lock.json + echo "package_lock.json + node_modules/ + .gitignore + " >> .gitignore if $INPUT_ONLY_CHANGED; then # --diff-filter=d excludes deleted files From 172c413f01afa0e9e6d7a175ad75acad76043479 Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:51:11 +0100 Subject: [PATCH 17/25] Added .gitignore exclusion --- entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/entrypoint.sh b/entrypoint.sh index 0baf63f..bda7d7f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -73,6 +73,7 @@ if _git_changed; then node_modules/ .gitignore " >> .gitignore + git config --global core.excludesfile .gitignore_global if $INPUT_ONLY_CHANGED; then # --diff-filter=d excludes deleted files From 1a89f28d0fbdf06934d64cf7ad3945ce9c1409b3 Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:54:40 +0100 Subject: [PATCH 18/25] Added .gitignore to exclusion - for real --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index bda7d7f..9359c77 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -73,7 +73,7 @@ if _git_changed; then node_modules/ .gitignore " >> .gitignore - git config --global core.excludesfile .gitignore_global + git config --global core.excludesfile .gitignore if $INPUT_ONLY_CHANGED; then # --diff-filter=d excludes deleted files From f4e4fcde26edbdcb6ebf00b43865070acb78ffc4 Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 18:56:55 +0100 Subject: [PATCH 19/25] Added .gitignore to exclusion - for real II --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 9359c77..16a4b42 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -73,7 +73,7 @@ if _git_changed; then node_modules/ .gitignore " >> .gitignore - git config --global core.excludesfile .gitignore + git update-index --skip-worktree .gitignore if $INPUT_ONLY_CHANGED; then # --diff-filter=d excludes deleted files From c9d8181bcf28179ff4cbb6627fb63c8045027ef0 Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 19:04:18 +0100 Subject: [PATCH 20/25] Moved ignore part to before git checks changed --- entrypoint.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 16a4b42..6ed784c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -59,6 +59,12 @@ echo "Prettifing files..." echo "Files:" prettier $INPUT_PRETTIER_OPTIONS || echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS" +# Ignore node modules and other action created files +echo "package_lock.json +node_modules/ +" >> .gitignore +git update-index --assume-unchanged .gitignore + # To keep runtime good, just continue if something was changed if _git_changed; then if $INPUT_DRY; then @@ -68,13 +74,6 @@ if _git_changed; then # Calling method to configure the git environemnt _git_setup - # Ignore node modules and other action created files - echo "package_lock.json - node_modules/ - .gitignore - " >> .gitignore - git update-index --skip-worktree .gitignore - if $INPUT_ONLY_CHANGED; then # --diff-filter=d excludes deleted files for file in $(git diff --name-only --diff-filter=d HEAD^..HEAD) From 19d31cb26373ebe7506c96f03e0d073e0e93a8dc Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 19:07:12 +0100 Subject: [PATCH 21/25] Another try at bugfixing the ignore mechanism --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 6ed784c..8dc8c5f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -63,7 +63,6 @@ prettier $INPUT_PRETTIER_OPTIONS || echo "Problem running prettier with $INPUT_P echo "package_lock.json node_modules/ " >> .gitignore -git update-index --assume-unchanged .gitignore # To keep runtime good, just continue if something was changed if _git_changed; then @@ -84,6 +83,7 @@ if _git_changed; then # Add changes to git git add "${INPUT_FILE_PATTERN}" || echo "Problem adding your files with pattern ${INPUT_FILE_PATTERN}" fi + git rm .gitignore # Commit and push changes back if $INPUT_SAME_COMMIT; then From 7d4939bf14f5b8e790b0c6232801ec61c371f476 Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 19:09:45 +0100 Subject: [PATCH 22/25] Another try at bugfixing the ignore mechanism --- entrypoint.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8dc8c5f..978dce1 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -60,9 +60,8 @@ echo "Files:" prettier $INPUT_PRETTIER_OPTIONS || echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS" # Ignore node modules and other action created files -echo "package_lock.json -node_modules/ -" >> .gitignore +git update-index --skip-worktree package_lock.json +git update-index --skip-worktree node_modules/ # To keep runtime good, just continue if something was changed if _git_changed; then @@ -83,7 +82,6 @@ if _git_changed; then # Add changes to git git add "${INPUT_FILE_PATTERN}" || echo "Problem adding your files with pattern ${INPUT_FILE_PATTERN}" fi - git rm .gitignore # Commit and push changes back if $INPUT_SAME_COMMIT; then From 5e56c643886c64170505a86fa95a03744b6f6bd2 Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 19:13:29 +0100 Subject: [PATCH 23/25] Another try at bugfixing the ignore mechanism --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 978dce1..98bcc42 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -60,8 +60,8 @@ echo "Files:" prettier $INPUT_PRETTIER_OPTIONS || echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS" # Ignore node modules and other action created files -git update-index --skip-worktree package_lock.json -git update-index --skip-worktree node_modules/ +rm -r node_modules/ +git reset --hard package-lock.json || rm package-lock.json # To keep runtime good, just continue if something was changed if _git_changed; then From 1f62e028b6c963411bf7a172190b76c0627e418c Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 19:16:25 +0100 Subject: [PATCH 24/25] Added exceptions to improve stability --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 98bcc42..1a9e514 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -60,8 +60,8 @@ echo "Files:" prettier $INPUT_PRETTIER_OPTIONS || echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS" # Ignore node modules and other action created files -rm -r node_modules/ -git reset --hard package-lock.json || rm package-lock.json +rm -r node_modules/ || echo "No node_modules/ folder." +git reset --hard package-lock.json || rm package-lock.json || echo "No node_modules/ folder." # To keep runtime good, just continue if something was changed if _git_changed; then From b81496839ae01ebae5800ff4146f9168ea4c46eb Mon Sep 17 00:00:00 2001 From: creyD Date: Fri, 19 Feb 2021 19:18:23 +0100 Subject: [PATCH 25/25] Adjusted exception message and finalized changes --- entrypoint.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 1a9e514..eb078cb 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -26,7 +26,6 @@ _git_changed() { } ( - # PROGRAM # Changing to the directory cd "$GITHUB_ACTION_PATH" @@ -61,7 +60,7 @@ prettier $INPUT_PRETTIER_OPTIONS || echo "Problem running prettier with $INPUT_P # Ignore node modules and other action created files rm -r node_modules/ || echo "No node_modules/ folder." -git reset --hard package-lock.json || rm package-lock.json || echo "No node_modules/ folder." +git reset --hard package-lock.json || rm package-lock.json || echo "No package-lock.json file." # To keep runtime good, just continue if something was changed if _git_changed; then