From f4def621ced84695f1d0bd3f46d67f26519bc0d0 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Sun, 12 Mar 2023 10:42:09 +0900 Subject: [PATCH 1/3] fix: fix a bug that action doesn't work well if working_directory isn't empty --- action.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/action.yaml b/action.yaml index c957452..3c59020 100644 --- a/action.yaml +++ b/action.yaml @@ -39,24 +39,23 @@ runs: run: git add ${{steps.find.outputs.checksum_file}} - shell: bash - working-directory: ${{inputs.working_directory}} if: fromJSON(inputs.skip_push) run: | - if ! git diff --cached --exit-code ${CHECKSUM_FILE}; then - echo "::error file=${CHECKSUM_FILE}::${CHECKSUM_FILE} isn't latest." + if ! git diff --cached --exit-code "${WORKING_DIR}/${CHECKSUM_FILE}"; then + echo "::error file=${WORKING_DIR}/${CHECKSUM_FILE}::${CHECKSUM_FILE} isn't latest." exit 1 fi env: CHECKSUM_FILE: ${{steps.find.outputs.checksum_file}} + WORKING_DIR: ${{inputs.working_directory}} - shell: bash - working-directory: ${{inputs.working_directory}} if: "! fromJSON(inputs.skip_push)" run: | - if git diff --cached --exit-code ${CHECKSUM_FILE}; then + if git diff --cached --exit-code "${WORKING_DIR}/${CHECKSUM_FILE}"; then exit 0 fi - echo "::error file=${CHECKSUM_FILE}::${CHECKSUM_FILE} isn't latest. A commit is pushed automatically to update ${CHECKSUM_FILE}." + echo "::error file=${WORKING_DIR}/${CHECKSUM_FILE}::${CHECKSUM_FILE} isn't latest. A commit is pushed automatically to update ${CHECKSUM_FILE}." if ! ghcp -v; then echo "::error ::int128/ghcp isn't installed. To push a commit, ghcp is required." @@ -70,7 +69,8 @@ runs: fi ghcp commit -r "$GITHUB_REPOSITORY" -b "$branch" \ -m "chore(aqua): update $CHECKSUM_FILE" \ - "$CHECKSUM_FILE" + "${WORKING_DIR}/$CHECKSUM_FILE" exit 1 env: CHECKSUM_FILE: ${{steps.find.outputs.checksum_file}} + WORKING_DIR: ${{inputs.working_directory}} From 563ff9c6cc31c84ad3defc03a0742027f7a6a251 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Sun, 12 Mar 2023 10:51:35 +0900 Subject: [PATCH 2/3] fix: set "." by default --- action.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 3c59020..c894a66 100644 --- a/action.yaml +++ b/action.yaml @@ -3,7 +3,6 @@ description: Update aqua-checksums.json inputs: working_directory: required: false - default: "" prune: required: false default: false @@ -26,6 +25,7 @@ runs: id: find working-directory: ${{inputs.working_directory}} run: | + set -eu for p in aqua-checksums.json .aqua-checksums.json aqua/aqua-checksums.json aqua/.aqua-checksums.json .aqua/aqua-checksums.json .aqua/.aqua-checksums.json; do if [ -f "$p" ]; then echo "checksum_file=$p" >> $GITHUB_OUTPUT @@ -41,6 +41,10 @@ runs: - shell: bash if: fromJSON(inputs.skip_push) run: | + set -eu + if [ -z "$WORKING_DIR" ]; then + WORKING_DIR=. + fi if ! git diff --cached --exit-code "${WORKING_DIR}/${CHECKSUM_FILE}"; then echo "::error file=${WORKING_DIR}/${CHECKSUM_FILE}::${CHECKSUM_FILE} isn't latest." exit 1 @@ -52,6 +56,10 @@ runs: - shell: bash if: "! fromJSON(inputs.skip_push)" run: | + set -eu + if [ -z "$WORKING_DIR" ]; then + WORKING_DIR=. + fi if git diff --cached --exit-code "${WORKING_DIR}/${CHECKSUM_FILE}"; then exit 0 fi From 3cd187ba721c8d7a5f70ce8cfa4ee7574bdebddb Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Sun, 12 Mar 2023 10:58:35 +0900 Subject: [PATCH 3/3] fix: fix CHECKSUM_FILE --- action.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/action.yaml b/action.yaml index c894a66..b8b2490 100644 --- a/action.yaml +++ b/action.yaml @@ -42,11 +42,11 @@ runs: if: fromJSON(inputs.skip_push) run: | set -eu - if [ -z "$WORKING_DIR" ]; then - WORKING_DIR=. + if [ -n "$WORKING_DIR" ]; then + CHECKSUM_FILE="$WORKING_DIR/$CHECKSUM_FILE" fi - if ! git diff --cached --exit-code "${WORKING_DIR}/${CHECKSUM_FILE}"; then - echo "::error file=${WORKING_DIR}/${CHECKSUM_FILE}::${CHECKSUM_FILE} isn't latest." + if ! git diff --cached --exit-code "${CHECKSUM_FILE}"; then + echo "::error file=${CHECKSUM_FILE}::${CHECKSUM_FILE} isn't latest." exit 1 fi env: @@ -57,13 +57,13 @@ runs: if: "! fromJSON(inputs.skip_push)" run: | set -eu - if [ -z "$WORKING_DIR" ]; then - WORKING_DIR=. + if [ -n "$WORKING_DIR" ]; then + CHECKSUM_FILE="$WORKING_DIR/$CHECKSUM_FILE" fi - if git diff --cached --exit-code "${WORKING_DIR}/${CHECKSUM_FILE}"; then + if git diff --cached --exit-code "${CHECKSUM_FILE}"; then exit 0 fi - echo "::error file=${WORKING_DIR}/${CHECKSUM_FILE}::${CHECKSUM_FILE} isn't latest. A commit is pushed automatically to update ${CHECKSUM_FILE}." + echo "::error file=${CHECKSUM_FILE}::${CHECKSUM_FILE} isn't latest. A commit is pushed automatically to update ${CHECKSUM_FILE}." if ! ghcp -v; then echo "::error ::int128/ghcp isn't installed. To push a commit, ghcp is required." @@ -77,7 +77,7 @@ runs: fi ghcp commit -r "$GITHUB_REPOSITORY" -b "$branch" \ -m "chore(aqua): update $CHECKSUM_FILE" \ - "${WORKING_DIR}/$CHECKSUM_FILE" + "$CHECKSUM_FILE" exit 1 env: CHECKSUM_FILE: ${{steps.find.outputs.checksum_file}}