Skip to content

Commit 92cf4d5

Browse files
chore(ci): migrate circleCI CI/CD to github actions to support trusted publishing to npmjs.com
1 parent 16ab817 commit 92cf4d5

File tree

12 files changed

+2397
-2637
lines changed

12 files changed

+2397
-2637
lines changed

.circleci/config.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.contentful/vault-secrets.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ services:
55
- dependabot
66
- packages-read
77
- semantic-release
8-
circleci:
9-
policies:
10-
- semantic-release-ecosystem

.github/workflows/build.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_call:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v5
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v6
19+
with:
20+
node-version: '24'
21+
cache: 'npm'
22+
23+
- name: Install latest npm
24+
run: npm install -g npm@latest
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Build
30+
run: npm run build
31+
32+
- name: Save Build folders
33+
uses: actions/cache/save@v4
34+
with:
35+
path: |
36+
dist
37+
key: build-cache-${{ github.run_id }}-${{ github.run_attempt }}

.github/workflows/check.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Run Checks
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_call:
8+
9+
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v5
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v6
19+
with:
20+
node-version: '24'
21+
cache: 'npm'
22+
23+
- name: Install latest npm
24+
run: npm install -g npm@latest
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Restore the build folders
30+
uses: actions/cache/restore@v4
31+
with:
32+
path: |
33+
dist
34+
key: build-cache-${{ github.run_id }}-${{ github.run_attempt }}
35+
36+
- name: Run linter
37+
run: npm run lint
38+
39+
- name: Check prettier formatting
40+
run: npm run prettier:check
41+
42+
- name: Run tests
43+
run: npm run test:cover
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ name: "CodeQL Scan for GitHub Actions Workflows"
33

44
on:
55
push:
6-
branches: [master]
7-
paths: [".github/workflows/**"]
8-
pull_request:
9-
branches: [master]
10-
paths: [".github/workflows/**"]
6+
branches: ['*']
117

128
jobs:
139
analyze:
@@ -19,14 +15,14 @@ jobs:
1915
security-events: write
2016

2117
steps:
22-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v5
2319

2420
- name: Initialize CodeQL
25-
uses: github/codeql-action/init@v3
21+
uses: github/codeql-action/init@v4
2622
with:
2723
languages: actions
2824

2925
- name: Run CodeQL Analysis
30-
uses: github/codeql-action/analyze@v3
26+
uses: github/codeql-action/analyze@v4
3127
with:
3228
category: actions

.github/workflows/dependabot-approve-and-request-merge.yml renamed to .github/workflows/dependabot-approve-and-request-merge.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ jobs:
77
permissions:
88
contents: write
99
id-token: write
10+
pull-requests: write
1011
runs-on: ubuntu-latest
1112
if: github.actor == 'dependabot[bot]'
1213
steps:
13-
- uses: contentful/github-auto-merge@v1
14+
- uses: contentful/github-auto-merge@v2
1415
with:
15-
VAULT_URL: ${{ secrets.VAULT_URL }}
16+
VAULT_URL: ${{ secrets.VAULT_URL }}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Create Issue on Workflow Failure
2+
3+
permissions:
4+
contents: read
5+
issues: write
6+
7+
on:
8+
workflow_call:
9+
inputs:
10+
workflow_name:
11+
description: 'Name of the failed workflow'
12+
required: true
13+
type: string
14+
job_name:
15+
description: 'Name of the failed job(s)'
16+
required: false
17+
type: string
18+
default: 'Unknown'
19+
failure_reason:
20+
description: 'Reason for the failure(s)'
21+
required: false
22+
type: string
23+
default: 'Unknown failure reason'
24+
25+
jobs:
26+
create-failure-issue:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v5
31+
32+
- name: Create Issue
33+
uses: actions/github-script@v7
34+
with:
35+
script: |
36+
const workflowName = '${{ inputs.workflow_name }}';
37+
const jobName = '${{ inputs.job_name }}';
38+
const failureReason = '${{ inputs.failure_reason }}';
39+
const runUrl = `${context.payload.repository.html_url}/actions/runs/${context.runId}`;
40+
const commitSha = context.sha;
41+
const commitUrl = `${context.payload.repository.html_url}/commit/${commitSha}`;
42+
const branch = context.ref.replace('refs/heads/', '');
43+
const actor = context.actor;
44+
45+
// Check if there's already an open issue for this workflow
46+
const existingIssues = await github.rest.issues.listForRepo({
47+
owner: context.repo.owner,
48+
repo: context.repo.repo,
49+
state: 'open',
50+
labels: 'workflow-failure,' + workflowName.toLowerCase().replace(/\s+/g, '-')
51+
});
52+
53+
const title = `🚨 Workflow Failure: ${workflowName}`;
54+
const body = `## Workflow Failure Report
55+
56+
**Workflow:** ${workflowName}
57+
**Job:** ${jobName}
58+
**Branch:** ${branch}
59+
**Commit:** [${commitSha.substring(0, 7)}](${commitUrl})
60+
**Triggered by:** @${actor}
61+
**Run URL:** [View Failed Run](${runUrl})
62+
63+
### Failure Details
64+
${failureReason}
65+
66+
### Debugging Information
67+
- **Timestamp:** ${new Date().toISOString()}
68+
- **Repository:** ${context.payload.repository.full_name}
69+
- **Event:** ${context.eventName}
70+
71+
### Next Steps
72+
1. Check the [workflow run logs](${runUrl}) for detailed error information
73+
2. Review the changes in [commit ${commitSha.substring(0, 7)}](${commitUrl})
74+
3. Fix the issue and re-run the workflow
75+
4. Close this issue once resolved
76+
77+
---
78+
*This issue was automatically created by the failure notification workflow.*`;
79+
80+
// If no existing open issue, create a new one
81+
if (existingIssues.data.length === 0) {
82+
await github.rest.issues.create({
83+
owner: context.repo.owner,
84+
repo: context.repo.repo,
85+
title: title,
86+
body: body,
87+
labels: [
88+
'workflow-failure',
89+
'bug',
90+
workflowName.toLowerCase().replace(/\s+/g, '-'),
91+
'automated'
92+
]
93+
});
94+
console.log(`Created new issue for ${workflowName} failure`);
95+
} else {
96+
console.log(`Issue already exists for ${workflowName} failure`);
97+
// Optionally add a comment to the existing issue
98+
await github.rest.issues.createComment({
99+
owner: context.repo.owner,
100+
repo: context.repo.repo,
101+
issue_number: existingIssues.data[0].number,
102+
body: `## Additional Failure Report
103+
104+
**New failure detected:**
105+
- **Job:** ${jobName}
106+
- **Commit:** [${commitSha.substring(0, 7)}](${commitUrl})
107+
- **Run URL:** [View Failed Run](${runUrl})
108+
- **Timestamp:** ${new Date().toISOString()}
109+
110+
${failureReason}`
111+
});
112+
console.log(`Added comment to existing issue for ${workflowName} failure`);
113+
}

.github/workflows/main.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
permissions:
3+
contents: read
4+
5+
on:
6+
push:
7+
branches: ['**']
8+
9+
jobs:
10+
build:
11+
uses: ./.github/workflows/build.yaml
12+
13+
check:
14+
needs: build
15+
uses: ./.github/workflows/check.yaml
16+
17+
release:
18+
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta')
19+
needs: [build, check]
20+
permissions:
21+
contents: write
22+
id-token: write
23+
actions: read
24+
uses: ./.github/workflows/release.yaml
25+
secrets:
26+
VAULT_URL: ${{ secrets.VAULT_URL }}
27+
28+
notify-failure:
29+
if: |
30+
always() &&
31+
(needs.build.result == 'failure' || needs.check.result == 'failure' || needs.release.result == 'failure') &&
32+
(github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/alpha')
33+
needs: [build, check, release]
34+
permissions:
35+
contents: read
36+
issues: write
37+
uses: ./.github/workflows/failure-notification.yaml
38+
with:
39+
workflow_name: "Main CI Pipeline"
40+
job_name: ${{ needs.build.result == 'failure' && 'build' || needs.check.result == 'failure' && 'check' || needs.release.result == 'failure' && 'release' || 'unknown' }}
41+
failure_reason: "One or more jobs in the main CI pipeline failed. Check the workflow run for detailed error information."

0 commit comments

Comments
 (0)