69 lines
2.0 KiB
YAML
69 lines
2.0 KiB
YAML
name: Publish
|
|
|
|
on:
|
|
release:
|
|
types:
|
|
- published
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request_target:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
website:
|
|
name: Publish website
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Find latest release
|
|
if: github.event_name == 'workflow_dispatch'
|
|
id: release
|
|
run: |
|
|
RELEASE=$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -s https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/latest | jq -r '.tag_name')
|
|
echo "Latest release: ${RELEASE}"
|
|
echo "release=${RELEASE}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Checkout
|
|
if: always()
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ steps.release.outputs.release || github.event.pull_request.head.sha }}
|
|
|
|
- name: Install NodeJS
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
registry-url: https://npm.pkg.github.com
|
|
scope: "@eveshipfit"
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set version
|
|
run: |
|
|
# Remove the "v" from the version.
|
|
VERSION=$(echo ${{ github.ref_name }} | cut -b2-)
|
|
echo "Version: ${VERSION}"
|
|
|
|
sed -i 's/"version": "0.0.0-git"/"version": "'${VERSION}'"/' package.json
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
npm install
|
|
# Force the latest (compatible) version of the data, without bumping the lock file explicitly.
|
|
npm update @eveshipfit/data
|
|
|
|
- name: Build website
|
|
run: npm run build
|
|
|
|
- name: Publish to Cloudflare Pages
|
|
uses: cloudflare/pages-action@v1
|
|
id: pages
|
|
with:
|
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
|
|
directory: dist
|
|
branch: ${{ github.event_name == 'release' && 'main' || github.event_name == 'workflow_dispatch' && 'main' || github.event_name == 'push' && 'latest' || format('pr/{0}', github.event.pull_request.number) }}
|