From 0fdb4561b38f4f28db2eb49a4fd408fffb14fb60 Mon Sep 17 00:00:00 2001 From: huni Date: Tue, 18 Jul 2023 02:34:13 +0900 Subject: [PATCH] fix: actions to exit gracefully by using conditionals --- .github/workflows/clear-alpha.yml | 2 +- .github/workflows/deploy-alpha.yml | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clear-alpha.yml b/.github/workflows/clear-alpha.yml index 87ce0a58..8ebaa2cf 100644 --- a/.github/workflows/clear-alpha.yml +++ b/.github/workflows/clear-alpha.yml @@ -22,7 +22,7 @@ jobs: - name: Remove Alpha Pages id: remove run: | - file_list=$(ls $base_path | grep alpha$pr_number) + file_list=$(ls $base_path | grep alpha$pr_number | cat) delimiter="$(openssl rand -hex 8)" echo "file_list<<$delimiter" >> $GITHUB_OUTPUT echo "$file_list" >> $GITHUB_OUTPUT diff --git a/.github/workflows/deploy-alpha.yml b/.github/workflows/deploy-alpha.yml index a4fff6ff..22bc4971 100644 --- a/.github/workflows/deploy-alpha.yml +++ b/.github/workflows/deploy-alpha.yml @@ -86,6 +86,7 @@ jobs: echo "pack_name=$(ls *.tgz)" >> $GITHUB_OUTPUT - name: Check if Still Pr is Open status + id: check-pr-status env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} @@ -95,10 +96,12 @@ jobs: if [ "$PR_STATE" != "open" ]; then echo "It seems that the PR is closed." - exit 1 fi + echo "pr_state=$PR_STATE" >> $GITHUB_OUTPUT + - name: Commit Alpha Pages + if: ${{ steps.check-pr-status.outputs.pr_state == 'open' }} id: deploy uses: stefanzweifel/git-auto-commit-action@v4 with: @@ -108,6 +111,7 @@ jobs: branch: main - name: Fetch Build Status Url + if: ${{ steps.check-pr-status.outputs.pr_state == 'open' }} id: fetch-build-status run: | url=$(bash .script/fetch-deploy-url.sh '${{ steps.deploy.outputs.commit_hash }}') @@ -115,6 +119,7 @@ jobs: echo "url=$url" >> $GITHUB_OUTPUT - name: Create Message + if: ${{ steps.check-pr-status.outputs.pr_state == 'open' }} run: | echo '## Alpha-${{ env.pr_number }} - ${{ env.sha }} @@ -132,6 +137,7 @@ jobs: ```' > message.txt - name: Message to Output + if: ${{ steps.check-pr-status.outputs.pr_state == 'open' }} id: message run: | body="$(cat message.txt)" @@ -141,12 +147,14 @@ jobs: echo "$delimiter" >> $GITHUB_OUTPUT - name: Comment PR Alpha Build + if: ${{ steps.check-pr-status.outputs.pr_state == 'open' }} uses: thollander/actions-comment-pull-request@v2 with: message: ${{ steps.message.outputs.body }} comment_tag: execution - name: Comment commit + if: ${{ steps.check-pr-status.outputs.pr_state == 'open' }} uses: peter-evans/commit-comment@v2 with: body: ${{ steps.message.outputs.body }}