Skip to content

[automated] Update JSON files (#582) #1438

[automated] Update JSON files (#582)

[automated] Update JSON files (#582) #1438

Workflow file for this run

name: Build, run tests, and deploy if necessary
on:
# Push to main and tag push
push:
branches:
- main
tags:
- '*'
# PR to main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Bun
uses: oven-sh/setup-bun@v1
- run: bun install
- name: Build project on tag push
if: github.ref != 'refs/heads/main'
run: bun run build
- name: Build project (staging)
if: github.ref == 'refs/heads/main'
run: bun run build-staging
- name: Run tests
run: bun test
- run: mv cdn out/
- uses: actions/upload-artifact@v4
# We only need to upload an artifact if this is not a pull request
if: github.repository == 'weirdgloop/osrs-dps-calc' && github.event_name != 'pull_request'
with:
name: output
path: out/
deploy:
runs-on: ubuntu-latest
needs: build
# Ensure that we only deploy to staging
if: github.repository == 'weirdgloop/osrs-dps-calc' && github.event_name != 'pull_request'
env:
DIRECTORY_NAME: ${{ github.ref == 'refs/heads/main' && 'osrs-dps-staging/' || 'osrs-dps/' }}
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: output
path: out
- name: Deploy to server
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.SSH_HOST }}
REMOTE_USER: ${{ secrets.SSH_USER }}
ARGS: "-rlgoDzvc -i --delete"
SOURCE: "out/"
TARGET: "/var/www/html/$DIRECTORY_NAME"
SCRIPT_AFTER: |
whoami
echo $RSYNC_STDOUT
- name: Purge cache on Cloudflare
run: |
curl --request POST \
--url https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE }}/purge_cache \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ${{ secrets.CLOUDFLARE_TOKEN }}' \
--data '{
"files": [
"https://tools.runescape.wiki/${{ env.DIRECTORY_NAME }}"
]
}'