mirror of
https://github.com/jellyfin/jellyfin.org.git
synced 2026-09-03 10:10:03 +03:00
149 lines
5.3 KiB
YAML
149 lines
5.3 KiB
YAML
name: deploy
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows:
|
|
- build
|
|
types:
|
|
- completed
|
|
|
|
jobs:
|
|
metadata:
|
|
name: Metadata
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' && github.repository == 'jellyfin/jellyfin.org' }}
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
pr_number: ${{ steps.pr_number.outputs.pr_number }}
|
|
steps:
|
|
- name: Get Pull Request Number
|
|
id: pr_number
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
|
|
run: |
|
|
API_RESPONSE=$(gh pr list --repo "${GITHUB_REPOSITORY}" --search "${HEAD_SHA}" --state open --json number)
|
|
PR_NUMBER=$(echo "${API_RESPONSE}" | jq -r '.[0].number // ""')
|
|
|
|
echo "repository: ${GITHUB_REPOSITORY}"
|
|
echo "sha: ${HEAD_SHA}"
|
|
echo "response: ${API_RESPONSE}"
|
|
echo "pr: ${PR_NUMBER}"
|
|
|
|
echo "pr_number=${PR_NUMBER}" >> "${GITHUB_OUTPUT}"
|
|
|
|
deploy:
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'master' && github.repository == 'jellyfin/jellyfin.org' }}
|
|
|
|
name: Deploy to GitHub Pages
|
|
permissions:
|
|
actions: read
|
|
pages: write
|
|
id-token: write
|
|
concurrency: build-deploy-pages
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Configure Pages
|
|
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
|
|
|
|
- name: Download workflow artifact
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
gh run download "${{ github.event.workflow_run.id }}" \
|
|
--repo "${GITHUB_REPOSITORY}" \
|
|
-n "jellyfin-org__build" \
|
|
-D build
|
|
|
|
- name: Create pages artifact
|
|
run: |
|
|
tar --dereference --hard-dereference \
|
|
--directory build \
|
|
-cvf "$RUNNER_TEMP/artifact.tar" \
|
|
--exclude=.git --exclude=.github .
|
|
|
|
- name: Upload pages artifact
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: github-pages
|
|
path: ${{ runner.temp }}/artifact.tar
|
|
retention-days: 1
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
|
|
|
|
preview:
|
|
needs: [metadata]
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch != 'master' }}
|
|
|
|
name: Deploy to Cloudflare Pages
|
|
permissions:
|
|
actions: read
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Set PR metadata
|
|
id: pr
|
|
run: |
|
|
echo "number=${{ needs.metadata.outputs.pr_number }}" >> $GITHUB_OUTPUT
|
|
echo "sha=${{ github.event.workflow_run.head_sha }}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Download workflow artifact
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
gh run download "${{ github.event.workflow_run.id }}" \
|
|
--repo "${GITHUB_REPOSITORY}" \
|
|
-n "jellyfin-org__build" \
|
|
-D build
|
|
|
|
- name: Add comment
|
|
if: ${{ needs.metadata.outputs.pr_number != '' }}
|
|
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
|
|
with:
|
|
github-token: ${{ secrets.JF_BOT_TOKEN }}
|
|
message: |
|
|
## Cloudflare Pages deployment
|
|
|
|
| **Latest commit** | <code>${{ steps.pr.outputs.sha }}</code> |
|
|
|-------------------|:-:|
|
|
| **Status** | 🔄 Deploying... |
|
|
| **Preview URL** | Not available |
|
|
| **Type** | 🔀 Preview |
|
|
pr-number: ${{ steps.pr.outputs.number }}
|
|
comment-tag: CFPages-deployment
|
|
mode: recreate
|
|
- name: Publish to Cloudflare
|
|
id: cf
|
|
uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4.0.0
|
|
with:
|
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
command: >
|
|
pages deploy build
|
|
--project-name=jellyfin-org
|
|
--branch=${{ github.event.workflow_run.head_repository.full_name }}/${{ github.event.workflow_run.head_branch }}
|
|
--commit-hash=${{ steps.pr.outputs.sha }}
|
|
|
|
- name: Update status comment
|
|
if: ${{ needs.metadata.outputs.pr_number != '' }}
|
|
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
|
|
with:
|
|
github-token: ${{ secrets.JF_BOT_TOKEN }}
|
|
message: |
|
|
## Cloudflare Pages deployment
|
|
|
|
| **Latest commit** | <code>${{ steps.pr.outputs.sha }}</code> |
|
|
|-------------------|:-:|
|
|
| **Status** | ${{ job.status == 'success' && '✅ Deployed!' || '❌ Failed!' }} |
|
|
| **Preview URL** | ${{ steps.cf.outputs.deployment-url || 'Not available' }} |
|
|
| **Type** | 🔀 Preview |
|
|
pr-number: ${{ steps.pr.outputs.number }}
|
|
comment-tag: CFPages-deployment
|
|
mode: recreate
|