Skip to content

Commit

Permalink
ci: major refactors (#2423)
Browse files Browse the repository at this point in the history
* Migrate CF Pages to CF Wrangler action (based on jellyfin/jellyfin-web#5894)
* Create event-based workflows, all the specific actions are now reusable workflows.
* Fix labeler definition file

Signed-off-by: Fernando Fernández <[email protected]>
  • Loading branch information
ferferga committed Aug 11, 2024
1 parent bc69685 commit 0356701
Show file tree
Hide file tree
Showing 13 changed files with 300 additions and 255 deletions.
43 changes: 27 additions & 16 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
tests:
- '**/*.spec.js'
- changed-files:
- any-glob-to-any-file:
- '**/*.spec.*'

github_actions:
- '.github/workflows/*'
ci:
- changed-files:
- any-glob-to-any-file:
- '.github/workflows/**/**'

pinia:
- 'frontend/store/**/*.ts'
'frontend:store':
- changed-files:
- any-glob-to-any-file:
- 'frontend/store/**/*.ts'

plugins:
- 'frontend/plugins/**/*.ts'
'frontend:plugins':
- changed-files:
- any-glob-to-any-file:
- 'frontend/plugins/**/*.ts'

vue:
- '**/*.vue'
- changed-files:
- any-glob-to-any-file:
- '**/*.vue'

docker:
- 'Dockerfile*'
packaging:
- changed-files:
- any-glob-to-any-file:
- 'packaging/**/**'

ui:
- any:
[
'frontend/components/**/*.vue',
'frontend/layouts/**/*.vue',
'frontend/pages/**/*.vue'
]
- changed-files:
- any-glob-to-any-file:
- 'frontend/components/**/*.vue'
- 'frontend/layouts/**/*.vue'
- 'frontend/pages/**/*.vue'
1 change: 1 addition & 0 deletions .github/workflows/TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Reusable workflows should be under a `reusable` folder. Track https://github.com/orgs/community/discussions/10773
25 changes: 6 additions & 19 deletions .github/workflows/codeql.yml → .github/workflows/__codeql.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
name: GitHub CodeQL 🔬

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.ref || github.head_ref || github.run_id }}
cancel-in-progress: true

on:
push:
branches:
- master
pull_request:
paths-ignore:
- '**/*.md'
merge_group:
workflow_call:
schedule:
- cron: 0 0 * * MON,FRI

inputs:
commit:
required: true
type: string
jobs:
analyze:
name: Analyze 🔬
name: Analyze ${{ matrix.language}} 🔬
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
Expand All @@ -35,6 +21,7 @@ jobs:
- name: Checkout repository ⬇️
uses: actions/[email protected]
with:
ref: ${{ inputs.commit }}
show-progress: false

- name: Initialize CodeQL 🛠️
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/__deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Deploy 🏗️

on:
workflow_call:
inputs:
branch:
required: true
type: string
commit:
required: false
type: string
comment:
required: false
type: boolean
artifact_name:
required: false
type: string
default: frontend

jobs:
cf-pages:
name: CloudFlare Pages 📃
runs-on: ubuntu-latest
environment: ${{ inputs.branch == 'master' && 'production' || 'preview' }}
outputs:
url: ${{ steps.cf.outputs.deployment-url }}

steps:
- name: Download workflow artifact ⬇️
uses: actions/[email protected]
with:
name: ${{ inputs.artifact_name }}
path: dist

- name: Publish to Cloudflare Pages 📃
uses: cloudflare/[email protected]
id: cf
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy dist --project-name=jf-vue --branch=${{ inputs.branch }}

compose-comment:
name: Compose and push comment 📝
# Always run so the comment is composed for the workflow summary
if: ${{ always() }}
uses: ./.github/workflows/__job_messages.yml
secrets: inherit
needs:
- cf-pages

with:
branch: ${{ inputs.branch }}
commit: ${{ inputs.commit }}
preview_url: ${{ needs.cf-pages.outputs.url }}
in_progress: false
comment: ${{ inputs.comment }}
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,23 @@ on:
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 }}
comment:
required: false
type: boolean
marker:
description: Hidden marker to detect PR comments composed by the bot
value: "CFPages-deployment"
required: false
type: string
default: "CFPages-deployment"


jobs:
msg:
name: Deployment status
cf_pages_msg:
name: CloudFlare Pages deployment status 📃🚀
runs-on: ubuntu-latest
outputs:
msg: ${{ env.msg }}

steps:
- name: Compose message 📃
Expand All @@ -45,8 +39,7 @@ jobs:
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...' || (inputs.preview_url != '' && '✅ Deployed!' || '❌ Failure. Check workflow logs for details') }}
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) }}
WORKFLOW_RUN: ${{ !inputs.in_progress && format('**[View build logs](https://github.com/{0}/actions/runs/{1})**', github.repository, github.run_id) || '' }}
# EOF is needed for multiline environment variables in a GitHub Actions context
run: |
echo "## Cloudflare Pages deployment" > $GITHUB_STEP_SUMMARY
Expand All @@ -57,9 +50,16 @@ jobs:
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 "$WORKFLOW_RUN" >> $GITHUB_STEP_SUMMARY
COMPOSED_MSG=$(cat $GITHUB_STEP_SUMMARY)
echo "msg<<EOF" >> $GITHUB_ENV
echo "$COMPOSED_MSG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Comment Pull Request
uses: thollander/[email protected]
if: ${{ inputs.comment }}
with:
GITHUB_TOKEN: ${{ secrets.JF_BOT_TOKEN }}
message: ${{ steps.compose.outputs.msg }}
comment_tag: ${{ inputs.marker }}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_call:
inputs:
commit:
required: true
required: false
type: string
tag_name:
required: false
Expand All @@ -28,10 +28,6 @@ env:
COMMIT_TAG: unstable
DOCKER_BUILD_RECORD_UPLOAD: false

permissions:
id-token: write
attestations: write

defaults:
run:
shell: bash
Expand Down Expand Up @@ -60,6 +56,7 @@ jobs:
- name: Checkout ⬇️
uses: actions/[email protected]
with:
ref: ${{ inputs.commit || github.sha }}
show-progress: false

- name: Setup node environment ⚙️
Expand Down Expand Up @@ -169,6 +166,7 @@ jobs:
- name: Checkout ⬇️
uses: actions/[email protected]
with:
ref: ${{ inputs.commit || github.sha }}
show-progress: false

- name: Configure QEMU ⚙️
Expand Down Expand Up @@ -262,6 +260,7 @@ jobs:
- name: Checkout ⬇️
uses: actions/[email protected]
with:
ref: ${{ inputs.commit || github.sha }}
show-progress: false

- name: Configure QEMU ⚙️
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
name: Quality checks 👌🧪

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
pull_request:
paths-ignore:
- '**/*.md'
merge_group:
schedule:
- cron: 30 7 * * 6
workflow_call:
inputs:
commit:
required: true
type: string
workflow_dispatch:

jobs:
Expand All @@ -21,6 +16,7 @@ jobs:
- name: Checkout Repository
uses: actions/[email protected]
with:
ref: ${{ inputs.commit }}
show-progress: false

- name: Scan
Expand All @@ -42,6 +38,7 @@ jobs:
- name: Checkout ⬇️
uses: actions/[email protected]
with:
ref: ${{ inputs.commit }}
show-progress: false

- name: Setup node environment ⚙️
Expand All @@ -67,6 +64,7 @@ jobs:
- name: Checkout ⬇️
uses: actions/[email protected]
with:
ref: ${{ inputs.commit }}
show-progress: false

- name: Setup node environment ⚙️
Expand All @@ -81,21 +79,15 @@ jobs:
- name: Run typecheck 📖
run: npm run typecheck

build:
name: Build 🏗️
uses: ./.github/workflows/package.yml
with:
commit: ${{ github.sha }}

conventional_commits:
name: Conventional commits check 💬
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
runs-on: ubuntu-latest

steps:
- name: Checkout ⬇️
uses: actions/[email protected]
with:
ref: ${{ inputs.commit }}
show-progress: false

- name: Check if all commits comply with the specification
Expand Down
Loading

0 comments on commit 0356701

Please sign in to comment.