mirror of
https://github.com/jellyfin/jellyfin.org.git
synced 2026-09-03 05:30:05 +03:00
Hotfix — replaces pull_request_target with pull_request to stop granting write permissions and secrets to fork PRs. Some workflows will break; can be fixed properly later.
131 lines
5.2 KiB
YAML
131 lines
5.2 KiB
YAML
name: build
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches: [master]
|
|
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
jobs:
|
|
build:
|
|
name: Build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
|
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
|
|
with:
|
|
cache: npm
|
|
node-version: 20
|
|
- name: Configure Pages
|
|
if: github.event_name == 'push' && github.repository == 'jellyfin/jellyfin.org'
|
|
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
|
|
- name: Run build
|
|
run: |
|
|
npm ci --no-audit
|
|
npm run build
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
|
with:
|
|
name: jellyfin-org__build
|
|
path: build
|
|
- name: Upload pages artifact
|
|
if: github.event_name == 'push' && github.repository == 'jellyfin/jellyfin.org'
|
|
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
|
|
with:
|
|
path: build
|
|
|
|
deploy:
|
|
if: github.event_name == 'push' && github.repository == 'jellyfin/jellyfin.org'
|
|
name: Deploy to GitHub Pages
|
|
concurrency: build-deploy-pages
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
|
|
|
|
publish:
|
|
if: github.event_name != 'push' && github.repository == 'jellyfin/jellyfin.org'
|
|
name: Deploy to Cloudflare Pages
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
steps:
|
|
- name: Add comment
|
|
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
|
|
if: github.event_name == 'pull_request'
|
|
with:
|
|
github-token: ${{ secrets.JF_BOT_TOKEN }}
|
|
message: |
|
|
## Cloudflare Pages deployment
|
|
|
|
| **Latest commit** | <code>${{ github.event.pull_request.head.sha || github.sha }}</code> |
|
|
|-------------------|:-:|
|
|
| **Status** | 🔄 Deploying... |
|
|
| **Preview URL** | Not available |
|
|
| **Type** | 🔀 Preview |
|
|
pr-number: ${{ github.event.pull_request.number }}
|
|
comment-tag: CFPages-deployment
|
|
mode: recreate
|
|
- name: Download workflow artifact
|
|
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
|
|
with:
|
|
name: jellyfin-org__build
|
|
path: build
|
|
- name: Publish to Cloudflare
|
|
id: cf
|
|
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1
|
|
with:
|
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
command: pages deploy build --project-name=jellyfin-org --branch=${{
|
|
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
|
|
&& (github.event.pull_request.head.ref || github.ref_name)
|
|
|| format('{0}/{1}', github.event.pull_request.head.repo.full_name, github.event.pull_request.head.ref)
|
|
}} --commit-hash=${{ github.event.pull_request.head.sha || github.sha }}
|
|
- name: Update status comment (Success)
|
|
if: ${{ github.event_name == 'pull_request' && success() }}
|
|
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
|
|
with:
|
|
github-token: ${{ secrets.JF_BOT_TOKEN }}
|
|
message: |
|
|
## Cloudflare Pages deployment
|
|
|
|
| **Latest commit** | <code>${{ github.event.pull_request.head.sha || github.sha }}</code> |
|
|
|-------------------|:-:|
|
|
| **Status** | ✅ Deployed! |
|
|
| **Preview URL** | ${{ steps.cf.outputs.deployment-url != '' && steps.cf.outputs.deployment-url || 'Not available' }} |
|
|
| **Type** | 🔀 Preview |
|
|
pr-number: ${{ github.event.pull_request.number }}
|
|
comment-tag: CFPages-deployment
|
|
mode: recreate
|
|
- name: Update status comment (Failure)
|
|
if: ${{ github.event_name == 'pull_request' && failure() }}
|
|
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
|
|
with:
|
|
github-token: ${{ secrets.JF_BOT_TOKEN }}
|
|
message: |
|
|
## Cloudflare Pages deployment
|
|
|
|
| **Latest commit** | <code>${{ github.event.pull_request.head.sha || github.sha }}</code> |
|
|
|-------------------|:-:|
|
|
| **Status** | ❌ Failure. Check workflow logs for details |
|
|
| **Preview URL** | Not available |
|
|
| **Type** | 🔀 Preview |
|
|
pr-number: ${{ github.event.pull_request.number }}
|
|
comment-tag: CFPages-deployment
|
|
mode: recreate
|