Wrote retrieve script & send script for steam bot #31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Discord Bot Deployment | |
on: | |
push: | |
branches: | |
- master # Change this to your main branch name | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Kill all running instances | |
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") | |
# 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 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 16 | |
- name: Install dependencies | |
run: npm install | |
- name: Deploy bot | |
run: | | |
# Any additional deployment steps you need, e.g., restarting the bot | |
npm start | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} |