Skip to content

Commit 131a2c3

Browse files
committed
ci: major refactors (#2423)
* 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]>
1 parent bc69685 commit 131a2c3

13 files changed

+301
-255
lines changed

.github/labeler.yml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
tests:
2-
- '**/*.spec.js'
2+
- changed-files:
3+
- any-glob-to-any-file:
4+
- '**/*.spec.*'
35

4-
github_actions:
5-
- '.github/workflows/*'
6+
ci:
7+
- changed-files:
8+
- any-glob-to-any-file:
9+
- '.github/workflows/**/**'
610

7-
pinia:
8-
- 'frontend/store/**/*.ts'
11+
'frontend:store':
12+
- changed-files:
13+
- any-glob-to-any-file:
14+
- 'frontend/store/**/*.ts'
915

10-
plugins:
11-
- 'frontend/plugins/**/*.ts'
16+
'frontend:plugins':
17+
- changed-files:
18+
- any-glob-to-any-file:
19+
- 'frontend/plugins/**/*.ts'
1220

1321
vue:
14-
- '**/*.vue'
22+
- changed-files:
23+
- any-glob-to-any-file:
24+
- '**/*.vue'
1525

16-
docker:
17-
- 'Dockerfile*'
26+
packaging:
27+
- changed-files:
28+
- any-glob-to-any-file:
29+
- 'packaging/**/**'
1830

1931
ui:
20-
- any:
21-
[
22-
'frontend/components/**/*.vue',
23-
'frontend/layouts/**/*.vue',
24-
'frontend/pages/**/*.vue'
25-
]
32+
- changed-files:
33+
- any-glob-to-any-file:
34+
- 'frontend/components/**/*.vue'
35+
- 'frontend/layouts/**/*.vue'
36+
- 'frontend/pages/**/*.vue'

.github/workflows/TODO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Reusable workflows should be under a `reusable` folder. Track https://github.com/orgs/community/discussions/10773. Right now, they're prefixed with `__`.

.github/workflows/codeql.yml renamed to .github/workflows/__codeql.yml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
11
name: GitHub CodeQL 🔬
22

3-
concurrency:
4-
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.ref || github.head_ref || github.run_id }}
5-
cancel-in-progress: true
6-
73
on:
8-
push:
9-
branches:
10-
- master
11-
pull_request:
12-
paths-ignore:
13-
- '**/*.md'
14-
merge_group:
154
workflow_call:
16-
schedule:
17-
- cron: 0 0 * * MON,FRI
18-
5+
inputs:
6+
commit:
7+
required: true
8+
type: string
199
jobs:
2010
analyze:
21-
name: Analyze 🔬
11+
name: Analyze ${{ matrix.language}} 🔬
2212
runs-on: ubuntu-latest
23-
permissions:
24-
actions: read
25-
contents: read
26-
security-events: write
2713

2814
strategy:
2915
fail-fast: false
@@ -35,6 +21,7 @@ jobs:
3521
- name: Checkout repository ⬇️
3622
uses: actions/[email protected]
3723
with:
24+
ref: ${{ inputs.commit }}
3825
show-progress: false
3926

4027
- name: Initialize CodeQL 🛠️

.github/workflows/__deploy.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Deploy 🏗️
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
branch:
7+
required: true
8+
type: string
9+
commit:
10+
required: false
11+
type: string
12+
comment:
13+
required: false
14+
type: boolean
15+
artifact_name:
16+
required: false
17+
type: string
18+
default: frontend
19+
20+
jobs:
21+
cf-pages:
22+
name: CloudFlare Pages 📃
23+
runs-on: ubuntu-latest
24+
environment:
25+
name: ${{ inputs.branch == 'master' && 'Production' || 'Preview' }}
26+
url: ${{ steps.cf.outputs.deployment-url }}
27+
outputs:
28+
url: ${{ steps.cf.outputs.deployment-url }}
29+
30+
steps:
31+
- name: Download workflow artifact ⬇️
32+
uses: actions/[email protected]
33+
with:
34+
name: ${{ inputs.artifact_name }}
35+
path: dist
36+
37+
- name: Publish to Cloudflare Pages 📃
38+
uses: cloudflare/[email protected]
39+
id: cf
40+
with:
41+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
42+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
43+
command: pages deploy dist --project-name=jf-vue --branch=${{ inputs.branch }}
44+
45+
compose-comment:
46+
name: Compose and push comment 📝
47+
# Always run so the comment is composed for the workflow summary
48+
if: ${{ always() }}
49+
uses: ./.github/workflows/__job_messages.yml
50+
secrets: inherit
51+
needs:
52+
- cf-pages
53+
54+
with:
55+
branch: ${{ inputs.branch }}
56+
commit: ${{ inputs.commit }}
57+
preview_url: ${{ needs.cf-pages.outputs.url }}
58+
in_progress: false
59+
comment: ${{ inputs.comment }}

.github/workflows/job_messages.yml renamed to .github/workflows/__job_messages.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,23 @@ on:
1212
preview_url:
1313
required: false
1414
type: string
15-
build_workflow_run_id:
16-
required: false
17-
type: number
18-
commenting_workflow_run_id:
19-
required: true
20-
type: string
2115
in_progress:
2216
required: true
2317
type: boolean
24-
outputs:
25-
msg:
26-
description: The composed message
27-
value: ${{ jobs.msg.outputs.msg }}
18+
comment:
19+
required: false
20+
type: boolean
2821
marker:
2922
description: Hidden marker to detect PR comments composed by the bot
30-
value: "CFPages-deployment"
23+
required: false
24+
type: string
25+
default: "CFPages-deployment"
26+
3127

3228
jobs:
33-
msg:
34-
name: Deployment status
29+
cf_pages_msg:
30+
name: CloudFlare Pages deployment 📃🚀
3531
runs-on: ubuntu-latest
36-
outputs:
37-
msg: ${{ env.msg }}
3832

3933
steps:
4034
- name: Compose message 📃
@@ -45,8 +39,7 @@ jobs:
4539
PREVIEW_URL: ${{ inputs.preview_url != '' && (inputs.branch != 'master' && inputs.preview_url || format('https://jf-vue.pages.dev ({0})', inputs.preview_url)) || 'Not available' }}
4640
DEPLOY_STATUS: ${{ inputs.in_progress && '🔄 Deploying...' || (inputs.preview_url != '' && '✅ Deployed!' || '❌ Failure. Check workflow logs for details') }}
4741
DEPLOYMENT_TYPE: ${{ inputs.branch != 'master' && '🔀 Preview' || '⚙️ Production' }}
48-
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) || '' }}
49-
COMMENTING_WORKFLOW_RUN: ${{ format('**[View bot logs](https://github.com/{0}/actions/runs/{1})**', 'jellyfin/jellyfin-vue', inputs.commenting_workflow_run_id) }}
42+
WORKFLOW_RUN: ${{ !inputs.in_progress && format('**[View build logs](https://github.com/{0}/actions/runs/{1})**', github.repository, github.run_id) || '' }}
5043
# EOF is needed for multiline environment variables in a GitHub Actions context
5144
run: |
5245
echo "## Cloudflare Pages deployment" > $GITHUB_STEP_SUMMARY
@@ -57,9 +50,16 @@ jobs:
5750
echo "| **Preview URL** | $PREVIEW_URL |" >> $GITHUB_STEP_SUMMARY
5851
echo "| **Type** | $DEPLOYMENT_TYPE |" >> $GITHUB_STEP_SUMMARY
5952
echo "" >> $GITHUB_STEP_SUMMARY
60-
echo "$BUILD_WORKFLOW_RUN" >> $GITHUB_STEP_SUMMARY
61-
echo "$COMMENTING_WORKFLOW_RUN" >> $GITHUB_STEP_SUMMARY
53+
echo "$WORKFLOW_RUN" >> $GITHUB_STEP_SUMMARY
6254
COMPOSED_MSG=$(cat $GITHUB_STEP_SUMMARY)
6355
echo "msg<<EOF" >> $GITHUB_ENV
6456
echo "$COMPOSED_MSG" >> $GITHUB_ENV
6557
echo "EOF" >> $GITHUB_ENV
58+
59+
- name: Push comment to Pull Request 🔼
60+
uses: thollander/[email protected]
61+
if: ${{ inputs.comment && steps.compose.conclusion == 'success' }}
62+
with:
63+
GITHUB_TOKEN: ${{ secrets.JF_BOT_TOKEN }}
64+
message: ${{ env.msg }}
65+
comment_tag: ${{ inputs.marker }}

.github/workflows/package.yml renamed to .github/workflows/__package.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_call:
55
inputs:
66
commit:
7-
required: true
7+
required: false
88
type: string
99
tag_name:
1010
required: false
@@ -28,10 +28,6 @@ env:
2828
COMMIT_TAG: unstable
2929
DOCKER_BUILD_RECORD_UPLOAD: false
3030

31-
permissions:
32-
id-token: write
33-
attestations: write
34-
3531
defaults:
3632
run:
3733
shell: bash
@@ -60,6 +56,7 @@ jobs:
6056
- name: Checkout ⬇️
6157
uses: actions/[email protected]
6258
with:
59+
ref: ${{ inputs.commit || github.sha }}
6360
show-progress: false
6461

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

174172
- name: Configure QEMU ⚙️
@@ -262,6 +260,7 @@ jobs:
262260
- name: Checkout ⬇️
263261
uses: actions/[email protected]
264262
with:
263+
ref: ${{ inputs.commit || github.sha }}
265264
show-progress: false
266265

267266
- name: Configure QEMU ⚙️

.github/workflows/quality_checks.yml renamed to .github/workflows/__quality_checks.yml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
name: Quality checks 👌🧪
22

3-
concurrency:
4-
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
5-
cancel-in-progress: true
6-
73
on:
8-
pull_request:
9-
paths-ignore:
10-
- '**/*.md'
11-
merge_group:
12-
schedule:
13-
- cron: 30 7 * * 6
4+
workflow_call:
5+
inputs:
6+
commit:
7+
required: true
8+
type: string
149
workflow_dispatch:
1510

1611
jobs:
@@ -21,6 +16,7 @@ jobs:
2116
- name: Checkout Repository
2217
uses: actions/[email protected]
2318
with:
19+
ref: ${{ inputs.commit }}
2420
show-progress: false
2521

2622
- name: Scan
@@ -42,6 +38,7 @@ jobs:
4238
- name: Checkout ⬇️
4339
uses: actions/[email protected]
4440
with:
41+
ref: ${{ inputs.commit }}
4542
show-progress: false
4643

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

7270
- name: Setup node environment ⚙️
@@ -81,21 +79,15 @@ jobs:
8179
- name: Run typecheck 📖
8280
run: npm run typecheck
8381

84-
build:
85-
name: Build 🏗️
86-
uses: ./.github/workflows/package.yml
87-
with:
88-
commit: ${{ github.sha }}
89-
9082
conventional_commits:
9183
name: Conventional commits check 💬
92-
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
9384
runs-on: ubuntu-latest
9485

9586
steps:
9687
- name: Checkout ⬇️
9788
uses: actions/[email protected]
9889
with:
90+
ref: ${{ inputs.commit }}
9991
show-progress: false
10092

10193
- name: Check if all commits comply with the specification

0 commit comments

Comments
 (0)