Skip to content

Commit

Permalink
feat: use cancel instead of returning error (#27)
Browse files Browse the repository at this point in the history
* feat: use cancel instead returning error

* ft: case-insensitive 1st char

* ci: update deprecated wf
  • Loading branch information
fearocanity authored Aug 14, 2024
1 parent 531ca7f commit a942b4e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/bot_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "run"
continue-on-error: true
Expand All @@ -66,7 +66,7 @@ jobs:
run: bash frame_main.sh "${tok_fb}" "${tok_gif}"

- name: "commit changes"
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "stat: Posted!!"
repository: .
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
run: |
case "${trig_actor}" in
"${repo_ownr}"|github-actions*) : ;;
*) printf '%s\n'"Runner prevented to run because the script is executed by an untrusted user \"${trig_actor}\". (Only owner can execute, for security)" >&2 ; exit 1 ;;
*) printf '%s\n'"Runner prevented to run because the script is executed by an untrusted user \"${trig_actor}\". (Only owner can execute, for security)" >&2
curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel" ;;
esac
- name: "chk wf status"
Expand All @@ -26,22 +27,31 @@ jobs:
response="$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/workflows/bot_runner.yml/runs")"
status="$(echo "${response}" | jq -r '.workflow_runs[].status')"
if grep -qE 'in_progress' <<< "${status}"; then
echo "The bot_runner is still running, The script prevented this workflow to run to avoid conflicts... Cancelling!!"
exit 1
echo -e '> [!CAUTION]'"\n> The bot_runner is still running, The script prevented this workflow to run to avoid conflicts... Cancelling"'!!' >> "${GITHUB_STEP_SUMMARY}"
# Cancel Job
curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel"
fi
: "Ignore"
inits:
runs-on: ubuntu-latest
if: success() && true
steps:
- name: "checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "check status"
run: |
if [ "$(<./fb/frameiterator)" -gt "$(sed -nE 's/.*total_frame="([^"]*)".*/\1/p' config.conf)" ]; then
echo -e '> [!NOTE]'"\n> The Bot was Finished Running" >> "${GITHUB_STEP_SUMMARY}"
curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel"
fi
- name: "execute"
run: bash img_process.sh "in_progress"

- name: "commit banner"
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "stat: Processing..."
repository: .
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/repo-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
check-repo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: "ownership check"
env:
trig_actor: ${{ github.triggering_actor }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:
Expand Down
6 changes: 3 additions & 3 deletions scripts/process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ process_subs(){
if (g ~ /[[:graph:]]\\N/) gsub(/\\N/," ",g)
gsub(/\\N/,"",g)
gsub(/\\h/,"",g)
if (f ~ /[^,]*,sign/) {
if (f ~ /[^,]*,[Ss]ign/) {
print "【"g"】"
} else if (f ~ /Signs,,/) {
} else if (f ~ /[Ss]igns,,/) {
print "\""g"\""
} else if (f ~ /Songs[^,]*,[^,]*,/) {
} else if (f ~ /[Ss]ongs[^,]*,[^,]*,/) {
print "『"g"』"
} else {
print g
Expand Down

0 comments on commit a942b4e

Please sign in to comment.