[automated] Update JSON files #2420
This file contains hidden or 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: 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@v6 | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Use Node.js 24.x | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24.x' | |
| cache: 'yarn' | |
| - run: yarn install | |
| - name: Build project on tag push | |
| if: github.ref != 'refs/heads/main' | |
| run: yarn run build | |
| - name: Build project (staging) | |
| if: github.ref == 'refs/heads/main' | |
| run: yarn run build-staging | |
| - 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 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 '{ | |
| "prefixes": [ | |
| "tools.runescape.wiki/${{ env.DIRECTORY_NAME }}" | |
| ] | |
| }' |