Skip to content

Commit 31da1d7

Browse files
authored
Merge pull request #2 from chriskyfung:feature/ci-cd
feat(ci): Implement CI/CD with GitHub Actions
2 parents e92c843 + 047c4eb commit 31da1d7

File tree

8 files changed

+160
-1
lines changed

8 files changed

+160
-1
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/release-drafter.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
categories:
2+
- title: '🚀 Features'
3+
labels:
4+
- 'feature'
5+
- 'feat'
6+
- title: '🐛 Bug Fixes'
7+
labels:
8+
- 'fix'
9+
- 'bug'
10+
- title: '📝 Documentation'
11+
labels:
12+
- 'docs'
13+
- 'documentation'
14+
- title: '🔧 Maintenance'
15+
labels:
16+
- 'chore'
17+
- 'refactor'
18+
template: |
19+
## What's Changed
20+
21+
$CHANGES

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v5
15+
16+
- name: Dependency Review
17+
uses: actions/dependency-review-action@v4
18+
19+
- name: Use Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
cache: 'npm'
24+
25+
- name: Install dependencies
26+
run: npm install
27+
28+
- name: Lint code
29+
run: npm run lint
30+
31+
- name: Run tests and collect coverage
32+
run: npm run test:coverage
33+
34+
- name: Upload coverage to Codecov
35+
uses: codecov/codecov-action@v5
36+
37+
- name: Build project
38+
run: npm run build

.github/workflows/codeql.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: '30 2 * * 1'
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
language: [ 'typescript' ]
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v5
24+
25+
- name: Initialize CodeQL
26+
uses: github/codeql-action/init@v3
27+
with:
28+
languages: ${{ matrix.language }}
29+
30+
- name: Autobuild
31+
uses: github/codeql-action/autobuild@v3
32+
33+
- name: Perform CodeQL Analysis
34+
uses: github/codeql-action/analyze@v3
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
update_release_draft:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: release-drafter/release-drafter@v5
13+
with:
14+
config-name: release-drafter.yml
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Todoist Task Reopener Cloudflare Worker
22

3+
[![CI](https://github.com/chriskyfung/todoist-reopener-worker/actions/workflows/ci.yml/badge.svg)](https://github.com/chriskyfung/todoist-reopener-worker/actions/workflows/ci.yml)
4+
[![codecov](https://codecov.io/gh/chriskyfung/todoist-reopener-worker/branch/main/graph/badge.svg)](https://codecov.io/gh/chriskyfung/todoist-reopener-worker)
5+
36
This project is a serverless Cloudflare Worker that automatically reopens completed Todoist tasks that have the label `tracked` or `routine`. It is designed as a robust, reliable, and secure replacement for a similar n8n workflow.
47

58
<figure style="text-align: center;">
@@ -16,6 +19,15 @@ The worker runs on a schedule, checking for recently completed tasks and reopeni
1619
- **Secure:** Uses Cloudflare's secrets store to manage the Todoist API token.
1720
- **Stateless:** Does not store any data.
1821

22+
## CI/CD
23+
24+
This project uses GitHub Actions to automate the development workflow. The following workflows are in place:
25+
26+
- **CI:** On every push and pull request to the `main` branch, the CI workflow runs linting, testing, and building to ensure code quality and that the project is always in a working state.
27+
- **CodeQL:** The CodeQL workflow runs on every push and pull request to the `main` branch to analyze the code for security vulnerabilities.
28+
- **Dependabot:** Dependabot is configured to automatically create pull requests to keep the project's dependencies up-to-date.
29+
- **Release Drafter:** The Release Drafter workflow automatically creates draft release notes as pull requests are merged, making it easier to create new releases.
30+
1931
## Technologies
2032

2133
- [Cloudflare Workers](https://workers.cloudflare.com/)

docs/development_plan.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,21 @@ This phase outlines the final steps to get the worker running live.
136136

137137
```bash
138138
npm run tail
139-
```
139+
```
140+
141+
## Phase 4: CI/CD and Automation
142+
143+
To ensure code quality, maintain security, and automate the development workflow, a CI/CD pipeline has been set up using GitHub Actions.
144+
145+
1. **Continuous Integration:** A CI workflow is configured to run on every push and pull request to the `main` branch. This workflow performs the following checks:
146+
* **Linting:** Ensures the code adheres to the project's coding standards.
147+
* **Testing:** Runs the test suite to verify the functionality of the worker.
148+
* **Building:** Compiles the TypeScript code to ensure it is valid.
149+
* **Dependency Review:** Scans for vulnerable dependencies to prevent introducing security risks.
150+
* **Test Coverage:** Uploads test coverage reports to Codecov to track the quality of the tests.
151+
152+
2. **Security Scanning:** A CodeQL workflow is set up to perform static analysis of the code to find security vulnerabilities.
153+
154+
3. **Dependency Management:** Dependabot is configured to automatically create pull requests to keep the project's dependencies up-to-date.
155+
156+
4. **Release Automation:** A Release Drafter workflow is in place to automatically create draft release notes as pull requests are merged, simplifying the release process.

docs/project_structure.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ This document outlines the file and directory structure for the Todoist Reopener
66

77
```
88
.
9+
├── .github
10+
│ ├── dependabot.yml
11+
│ ├── release-drafter.yml
12+
│ └── workflows
13+
│ ├── ci.yml
14+
│ ├── codeql.yml
15+
│ └── release-drafter.yml
916
├── .eslintrc.cjs
1017
├── Dockerfile
1118
├── LICENSE
@@ -33,6 +40,14 @@ This document outlines the file and directory structure for the Todoist Reopener
3340
- **`src/`**: This directory holds all of your worker's source code.
3441
- **`index.ts`**: This is the main entry point for the worker. It will contain all the TypeScript logic that gets executed when the cron trigger fires. This includes connecting to the Todoist API, fetching completed tasks, and sending the requests to reopen them.
3542

43+
- **`.github/`**: This directory contains all the GitHub Actions workflows and configurations.
44+
- **`dependabot.yml`**: Configuration for Dependabot to automatically update dependencies.
45+
- **`release-drafter.yml`**: Configuration for Release Drafter to automatically draft release notes.
46+
- **`workflows/`**: This directory contains all the GitHub Actions workflows.
47+
- **`ci.yml`**: The main CI/CD workflow that runs linting, testing, and building.
48+
- **`codeql.yml`**: The workflow for CodeQL to analyze the code for security vulnerabilities.
49+
- **`release-drafter.yml`**: The workflow for Release Drafter.
50+
3651
- **`docs/`**: This directory contains all the project documentation.
3752
- **`development_plan.md`**: This document outlines the plan to migrate the n8n workflow to a robust and reliable Cloudflare Worker.
3853
- **`project_structure.md`**: This document outlines the file and directory structure for the Todoist Reopener Cloudflare Worker project.

0 commit comments

Comments
 (0)