mirror of
https://github.com/jellyfin/jellyfin-vue.git
synced 2026-09-03 05:10:26 +03:00
ci: improvements to CF deployment messages
* Shorter version of commit sha * Show normal URL when deploying to master * Reusable job system workflow * Add links to workflow runs for easier debugging
This commit is contained in:
committed by
GitHub
parent
2401ee3110
commit
96692347ea
@@ -7,35 +7,28 @@ on:
|
||||
pull_request_target:
|
||||
|
||||
jobs:
|
||||
comment:
|
||||
name: Create system comment 🖥️
|
||||
if: ${{ github.event_name == 'pull_request_target'}}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Create job summary and add to environment
|
||||
env:
|
||||
COMMIT: ${{ github.event.pull_request.head.sha }}
|
||||
# EOF is needed for multiline environment variables in a GitHub Actions context
|
||||
run: |
|
||||
echo "## Cloudflare Pages deployment" > $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| **Latest commit** | `$COMMIT` |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "|------------------------- |:----------------------------: |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| **Status** | 🔄 Deploying... |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| **Preview URL** | Not available yet |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "<!--- CFPages deployment marker --->" >> $GITHUB_STEP_SUMMARY
|
||||
COMPOSED_MSG=$(cat $GITHUB_STEP_SUMMARY)
|
||||
echo "msg<<EOF" >> $GITHUB_ENV
|
||||
echo "$COMPOSED_MSG" >> $GITHUB_ENV
|
||||
echo "EOF" >> $GITHUB_ENV
|
||||
compose-comment:
|
||||
name: Compose PR comment
|
||||
if: ${{ always() && github.event_name == 'pull_request_target' }}
|
||||
uses: ./.github/workflows/job_messages.yml
|
||||
with:
|
||||
commit: ${{ github.event.pull_request.head.sha }}
|
||||
commenting_workflow_run_id: ${{ github.run_id }}
|
||||
in_progress: true
|
||||
|
||||
- name: Create CF Pages deployment comment
|
||||
uses: thollander/actions-comment-pull-request@v1.5.0
|
||||
push-comment:
|
||||
name: Push comment to PR 🖥️
|
||||
if: ${{ always() && github.event_name == 'pull_request_target' && needs.compose-comment.result == 'success' }}
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- compose-comment
|
||||
|
||||
steps:
|
||||
- uses: thollander/actions-comment-pull-request@v1.5.0
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.JF_BOT_TOKEN }}
|
||||
message: ${{ env.msg }}
|
||||
comment_includes: '<!--- CFPages deployment marker --->'
|
||||
message: ${{ needs.compose-comment.outputs.msg }}
|
||||
comment_includes: ${{ needs.compose-comment.outputs.marker }}
|
||||
|
||||
project:
|
||||
name: Project board 📊
|
||||
|
||||
@@ -189,20 +189,24 @@ jobs:
|
||||
name: jellyfin-vue_windows_amd64
|
||||
path: tauri/target/release/jellyfin-vue.exe
|
||||
|
||||
pr_number:
|
||||
name: Save PR number as artifact
|
||||
pr_context:
|
||||
name: Save PR context as artifact
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Save PR number
|
||||
- name: Save PR context
|
||||
env:
|
||||
PR_NUMBER: ${{ github.event.number }}
|
||||
PR_SHA: ${{ github.sha }}
|
||||
run: |
|
||||
echo $PR_NUMBER > PR_number
|
||||
echo $PR_SHA > PR_sha
|
||||
|
||||
- name: Upload PR number as artifact
|
||||
uses: actions/upload-artifact@v3.1.1
|
||||
with:
|
||||
name: PR_number
|
||||
path: PR_number
|
||||
name: PR_context
|
||||
path: |
|
||||
PR_number
|
||||
PR_sha
|
||||
|
||||
@@ -11,68 +11,81 @@ on:
|
||||
jobs:
|
||||
cf-pages:
|
||||
name: CloudFlare Pages 📃
|
||||
if: ${{ always() && github.event.workflow_run.conclusion == 'success' }}
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
url: ${{ steps.cf.outputs.url }}
|
||||
|
||||
steps:
|
||||
- name: Download workflow artifact ⬇️
|
||||
uses: dawidd6/action-download-artifact@v2.24.2
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
with:
|
||||
run_id: ${{ inputs.workflow_run_id != '' && inputs.workflow_run_id || github.event.workflow_run.id }}
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
name: frontend
|
||||
path: dist
|
||||
|
||||
- name: Publish to Cloudflare Pages 📃
|
||||
uses: cloudflare/pages-action@v1.1.0
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
id: cf
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
projectName: jf-vue
|
||||
directory: dist
|
||||
branch: ${{ inputs.branch != '' && inputs.branch || github.event.workflow_run.head_branch }}
|
||||
branch: ${{ github.event.workflow_run.head_branch }}
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Create job summary
|
||||
id: msg
|
||||
env:
|
||||
COMMIT: ${{ github.event.workflow_run.head_commit.id }}
|
||||
PREVIEW_URL: ${{ steps.cf.outputs.url != '' && steps.cf.outputs.url || 'Not available' }}
|
||||
DEPLOY_STATUS: ${{ steps.cf.outputs.url != '' && '✅ Deployed!' || '❌ Failure. Check workflow logs for more info' }}
|
||||
# EOF is needed for multiline environment variables in a GitHub Actions context
|
||||
run: |
|
||||
echo "## Cloudflare Pages deployment" > $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| **Latest commit** | `$COMMIT` |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "|------------------------- |:----------------------------: |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| **Status** | $DEPLOY_STATUS |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| **Preview URL** | $PREVIEW_URL |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "<!--- CFPages deployment marker --->" >> $GITHUB_STEP_SUMMARY
|
||||
COMPOSED_MSG=$(cat $GITHUB_STEP_SUMMARY)
|
||||
echo "msg<<EOF" >> $GITHUB_ENV
|
||||
echo "$COMPOSED_MSG" >> $GITHUB_ENV
|
||||
echo "EOF" >> $GITHUB_ENV
|
||||
pr-context:
|
||||
name: Get PR context
|
||||
if: ${{ always() && github.event.workflow_run.event == 'pull_request' }}
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
commit: ${{ env.pr_sha }}
|
||||
pr_number: ${{ env.pr_number }}
|
||||
|
||||
- name: Get PR number ⬇️
|
||||
steps:
|
||||
- name: Get PR context ⬇️
|
||||
uses: dawidd6/action-download-artifact@v2.24.2
|
||||
if: ${{ github.event.workflow_run.event == 'pull_request' }}
|
||||
id: pr_context
|
||||
with:
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
name: PR_number
|
||||
name: PR_context
|
||||
|
||||
- name: Set PR number environment variable
|
||||
if: ${{ github.event.workflow_run.event == 'pull_request' }}
|
||||
- name: Set PR context environment variables
|
||||
if: ${{ steps.pr_context.conclusion == 'success' }}
|
||||
run: |
|
||||
PR_NUMBER=$(cat PR_number)
|
||||
echo "pr_number=$PR_NUMBER" >> $GITHUB_ENV
|
||||
echo "pr_number=$(cat PR_number)" >> $GITHUB_ENV
|
||||
echo "pr_sha=$(cat PR_sha)" >> $GITHUB_ENV
|
||||
|
||||
compose-comment:
|
||||
name: Compose comment
|
||||
if: ${{ always() && github.event.workflow_run.event == 'pull_request' }}
|
||||
uses: ./.github/workflows/job_messages.yml
|
||||
needs:
|
||||
- cf-pages
|
||||
- pr-context
|
||||
with:
|
||||
branch: ${{ github.event.workflow_run.head_branch }}
|
||||
commit: ${{ needs.pr-context.commit != '' && needs.pr-context.commit || github.event.workflow_run.head_sha }}
|
||||
preview_url: ${{ needs.cf-pages.url }}
|
||||
build_workflow_run_id: ${{ github.event.workflow_run.id }}
|
||||
commenting_workflow_run_id: ${{ github.run_id }}
|
||||
in_progress: false
|
||||
|
||||
comment-status:
|
||||
name: Create comment status
|
||||
if: ${{ always() && github.event.workflow_run.event == 'pull_request' && needs.pr-context.outputs.pr_number != '' }}
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- compose-comment
|
||||
- pr-context
|
||||
|
||||
steps:
|
||||
- name: Update job summary in PR comment
|
||||
uses: thollander/actions-comment-pull-request@v1.5.0
|
||||
if: ${{ github.event.workflow_run.event == 'pull_request' }}
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.JF_BOT_TOKEN }}
|
||||
message: ${{ env.msg }}
|
||||
pr_number: ${{ env.pr_number }}
|
||||
comment_includes: '<!--- CFPages deployment marker --->'
|
||||
message: ${{ needs.compose-comment.outputs.msg }}
|
||||
pr_number: ${{ needs.pr-context.outputs.pr_number }}
|
||||
comment_includes: ${{ needs.compose-comment.outputs.marker }}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
name: Job messages ⚙️
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
branch:
|
||||
required: false
|
||||
type: string
|
||||
commit:
|
||||
required: true
|
||||
type: string
|
||||
preview_url:
|
||||
required: false
|
||||
type: string
|
||||
build_workflow_run_id:
|
||||
required: false
|
||||
type: number
|
||||
commenting_workflow_run_id:
|
||||
required: true
|
||||
type: string
|
||||
in_progress:
|
||||
required: true
|
||||
type: boolean
|
||||
outputs:
|
||||
msg:
|
||||
description: The composed message
|
||||
value: ${{ jobs.msg.outputs.msg }}
|
||||
marker:
|
||||
description: Hidden marker to detect PR comments composed by the bot
|
||||
value: ${{ jobs.msg.outputs.comment_marker }}
|
||||
|
||||
jobs:
|
||||
msg:
|
||||
name: Deployment status
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
COMMENT_MARKER: '<!--- CFPages deployment marker --->'
|
||||
outputs:
|
||||
msg: ${{ env.msg }}
|
||||
comment_marker: ${{ env.COMMENT_MARKER }}
|
||||
|
||||
steps:
|
||||
- name: Compose message 📃
|
||||
if: ${{ always() }}
|
||||
id: compose
|
||||
env:
|
||||
COMMIT: ${{ inputs.commit }}
|
||||
PREVIEW_URL: ${{ inputs.preview_url != '' && (inputs.branch != 'master' && inputs.preview_url || format('https://jf-vue.pages.dev ({0})', inputs.preview_url)) || 'Not available' }}
|
||||
DEPLOY_STATUS: ${{ inputs.in_progress && '🔄 Deploying...' || (steps.cf.outputs.url != '' && '✅ Deployed!' || '❌ Failure. Check workflow logs for more info') }}
|
||||
DEPLOYMENT_TYPE: ${{ inputs.branch != 'master' && '🔀 Preview' || '⚙️ Production' }}
|
||||
BUILD_WORKFLOW_RUN: ${{ !inputs.in_progress && format('**[View build logs](https://github.com/{0}/actions/runs/{1})**', 'jellyfin/jellyfin-vue', inputs.build_workflow_run_id) || '' }}
|
||||
COMMENTING_WORKFLOW_RUN: ${{ format('**[View bot logs](https://github.com/{0}/actions/runs/{1})**', 'jellyfin/jellyfin-vue', inputs.commenting_workflow_run_id) }}
|
||||
# EOF is needed for multiline environment variables in a GitHub Actions context
|
||||
run: |
|
||||
echo "## Cloudflare Pages deployment" > $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| **Latest commit** | <code>${COMMIT::7}</code> |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "|------------------------- |:----------------------------: |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| **Status** | $DEPLOY_STATUS |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| **Preview URL** | $PREVIEW_URL |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| **Type** | $DEPLOYMENT_TYPE |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "$BUILD_WORKFLOW_RUN" >> $GITHUB_STEP_SUMMARY
|
||||
echo "$COMMENTING_WORKFLOW_RUN" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "$COMMENT_MARKER" >> $GITHUB_STEP_SUMMARY
|
||||
COMPOSED_MSG=$(cat $GITHUB_STEP_SUMMARY)
|
||||
echo "msg<<EOF" >> $GITHUB_ENV
|
||||
echo "$COMPOSED_MSG" >> $GITHUB_ENV
|
||||
echo "EOF" >> $GITHUB_ENV
|
||||
Reference in New Issue
Block a user