Skip to content

Commit

Permalink
Changed package.json and deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
JHVIW committed Oct 4, 2023
1 parent 5aa8749 commit e90b1b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
27 changes: 11 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,27 @@ jobs:

steps:

- name: Kill all running instances
- name: Kill the last running instance
run: |
# Define your GitHub Personal Access Token (PAT) with workflow permissions
GITHUB_TOKEN=${{ secrets.GH_TOKEN }}
# Get the current workflow run ID
WORKFLOW_RUN_ID=$(echo $GITHUB_RUN_ID)
# Get the list of workflow runs for the current workflow
RUNS=$(curl -s -X GET "https://api.github.com/repos/JHVIW/Secret-Santa-Bot/actions/runs" -H "Authorization: token $GITHUB_TOKEN")
# Get the list of workflow runs for the current workflow and sort them by created_at
RUNS=$(curl -s -X GET "https://api.github.com/repos/JHVIW/Secret-Santa-Bot/actions/runs" -H "Authorization: token $GITHUB_TOKEN" | jq -r '.workflow_runs | sort_by(.created_at) | .[] | .id')
# Loop through each run and cancel if it's not the current run
for row in $(echo "${RUNS}" | jq -r '.workflow_runs[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
RUN_ID=$(_jq '.id')
if [ "$RUN_ID" != "$WORKFLOW_RUN_ID" ]; then
curl -s -X POST "https://api.github.com/repos/${{ github.repository }}/actions/runs/$RUN_ID/cancel" -H "Authorization: token $GITHUB_TOKEN"
fi
done
# Get the last run (which will be the most recent)
LAST_RUN_ID=$(echo "$RUNS" | tail -n 1)
# Cancel the last run if it's not the current run
if [ "$LAST_RUN_ID" != "$WORKFLOW_RUN_ID" ]; then
curl -s -X POST "https://api.github.com/repos/${{ github.repository }}/actions/runs/$LAST_RUN_ID/cancel" -H "Authorization: token $GITHUB_TOKEN"
fi
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

- name: Checkout code
uses: actions/checkout@v2

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node discord_bot\\bot.js && node steam_bot\\retreive.js && steam_bot\\send.js"
"start": "node discord_bot/bot.js && node steam_bot/retreive.js && node steam_bot/send.js"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit e90b1b8

Please sign in to comment.