More base presets #554
Workflow file for this run
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: Main | |
on: | |
# Push to main branch | |
push: | |
branches: | |
- main | |
# PR to main branch | |
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 Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
cache: 'yarn' | |
- uses: actions/cache@v3 | |
id: yarn-cache | |
with: | |
path: | | |
${{ github.workspace }}/.next/cache | |
# Generate a new cache whenever packages or source files change. | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}- | |
- name: Install dependencies | |
run: yarn | |
- name: Build project | |
run: yarn build | |
- name: Run tests | |
run: yarn test | |
- run: mv cdn out/ | |
- uses: actions/upload-artifact@v4 | |
# We only need to upload an artifact if this is a push to the main branch | |
if: github.ref == 'refs/heads/main' | |
with: | |
name: output | |
path: out/ | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
# Ensure that we only deploy when pushing to the main branch | |
if: github.repository == 'weirdgloop/osrs-dps-calc' && github.ref == 'refs/heads/main' | |
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/osrs-dps/" | |
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/osrs-dps/" | |
] | |
}' |