Skip to content

Commit 0fdb456

Browse files
committed
fix: actions to exit gracefully by using conditionals
1 parent 293b754 commit 0fdb456

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.github/workflows/clear-alpha.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Remove Alpha Pages
2323
id: remove
2424
run: |
25-
file_list=$(ls $base_path | grep alpha$pr_number)
25+
file_list=$(ls $base_path | grep alpha$pr_number | cat)
2626
delimiter="$(openssl rand -hex 8)"
2727
echo "file_list<<$delimiter" >> $GITHUB_OUTPUT
2828
echo "$file_list" >> $GITHUB_OUTPUT

.github/workflows/deploy-alpha.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ jobs:
8686
echo "pack_name=$(ls *.tgz)" >> $GITHUB_OUTPUT
8787
8888
- name: Check if Still Pr is Open status
89+
id: check-pr-status
8990
env:
9091
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9192
PR_NUMBER: ${{ github.event.pull_request.number }}
@@ -95,10 +96,12 @@ jobs:
9596
9697
if [ "$PR_STATE" != "open" ]; then
9798
echo "It seems that the PR is closed."
98-
exit 1
9999
fi
100100
101+
echo "pr_state=$PR_STATE" >> $GITHUB_OUTPUT
102+
101103
- name: Commit Alpha Pages
104+
if: ${{ steps.check-pr-status.outputs.pr_state == 'open' }}
102105
id: deploy
103106
uses: stefanzweifel/git-auto-commit-action@v4
104107
with:
@@ -108,13 +111,15 @@ jobs:
108111
branch: main
109112

110113
- name: Fetch Build Status Url
114+
if: ${{ steps.check-pr-status.outputs.pr_state == 'open' }}
111115
id: fetch-build-status
112116
run: |
113117
url=$(bash .script/fetch-deploy-url.sh '${{ steps.deploy.outputs.commit_hash }}')
114118
echo "url=$url"
115119
echo "url=$url" >> $GITHUB_OUTPUT
116120
117121
- name: Create Message
122+
if: ${{ steps.check-pr-status.outputs.pr_state == 'open' }}
118123
run: |
119124
echo '## Alpha-${{ env.pr_number }} - ${{ env.sha }}
120125
@@ -132,6 +137,7 @@ jobs:
132137
```' > message.txt
133138
134139
- name: Message to Output
140+
if: ${{ steps.check-pr-status.outputs.pr_state == 'open' }}
135141
id: message
136142
run: |
137143
body="$(cat message.txt)"
@@ -141,12 +147,14 @@ jobs:
141147
echo "$delimiter" >> $GITHUB_OUTPUT
142148
143149
- name: Comment PR Alpha Build
150+
if: ${{ steps.check-pr-status.outputs.pr_state == 'open' }}
144151
uses: thollander/actions-comment-pull-request@v2
145152
with:
146153
message: ${{ steps.message.outputs.body }}
147154
comment_tag: execution
148155

149156
- name: Comment commit
157+
if: ${{ steps.check-pr-status.outputs.pr_state == 'open' }}
150158
uses: peter-evans/commit-comment@v2
151159
with:
152160
body: ${{ steps.message.outputs.body }}

0 commit comments

Comments
 (0)