Skip to content

Commit 71a18df

Browse files
authored
Chore(github-actions) : add CI/CD workflows guidelines and improve naming conventions (#789)
* chore(ci.yml) improve naming of ci.yml workflow * chore(issue.yml) : improve workflow steps, jobs name for better clarity and consistency * chore(link.yml & pr_target.yml) : Improve docs * renamed links.yml and stale.yml * Added workflow guidelines documentation
1 parent 10bb5d4 commit 71a18df

File tree

6 files changed

+89
-28
lines changed

6 files changed

+89
-28
lines changed

.github/workflows/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
## JSON Schema Website CI/CD Workflow Guidelines
2+
3+
### Overview
4+
5+
This document outlines the guidelines for contributing to and maintaining GitHub Actions workflows in the JSON Schema Website project. Adherence to these guidelines ensures consistency, efficiency, and ease of maintenance across our CI/CD processes.
6+
7+
### General Principles
8+
9+
- **Change Management**: Modifications to files in this directory are closely monitored. Changes will trigger unauthorized file changes workflow during pull request checks. Only make changes when explicitly advised by a project contributor or maintainer.
10+
- **Documentation and Naming**: Use descriptive, self-explanatory names for workflows, jobs, and steps. Include clear comments within workflow files to explain complex configurations.
11+
12+
### YAML Workflow File Structure
13+
14+
Our YAML files are organized based on specific roles and event triggers. When creating or modifying workflows, ensure that:
15+
- The file roles described below are strictly maintained.
16+
- Job sequences within workflows are preserved using [GitHub Action job dependencies](https://docs.github.com/en/actions/using-workflows/using-jobs-in-a-workflow#defining-prerequisite-jobs).
17+
18+
### File Categorization
19+
20+
Organize workflow files based on their primary event trigger:
21+
22+
- **Issue Workflows**:
23+
- [Issue Workflow](./issue.yml): Handles issue-related events such as opening, closing, or labeling issues.
24+
25+
- **Pull Request Workflows**:
26+
- [CI Workflow](./ci.yml): Runs for all contributors on pull requests, performing code-quality checks, unauthorized file changes detection, and build processes.
27+
- [PR Interaction Workflow](./pull-request-target.yml): Contains workflows specifically for first-time contributors, such as welcome messages.
28+
29+
### Exceptions to File Categorization
30+
31+
Separate files may be created for workflows that:
32+
33+
- Require unique `cron` schedules for periodic execution.
34+
Examples:
35+
- [Link Checker](./link-checker.yml): Periodically checks for broken links in the repository.
36+
- [Mark stale issues and pull requests](./stale-issues-prs.yml): Automatically labels and closes stale issues and PRs.
37+
- [Dependabot](../dependabot.yml): Keeps dependencies up-to-date.
38+
39+
- Need specific `paths` triggers, activating only when files in particular directories are modified.
40+
Example:
41+
- [New Implementation Commenter](./new-implementation.yml): Adds comments when new implementation files are added.
42+
43+
- Only work correctly if they have a dedicated file.
44+
Examples:
45+
- [Preview Deployment](./preview-deployment.yml): Deploys preview environments for pull requests.
46+
- [Production Deployment](./production-deployment.yml): Handles production deployments.
47+
- [CodeQL Code Scanning](./codeql.yml): Performs code security analysis.
48+
- [Check PR Dependencies](./pr-dependencies.yml): Enforces dependencies between PRs based on opening comments.
49+
50+
### Workflow Maintenance
51+
52+
To ensure the efficiency and reliability of our workflows, follow these maintenance guidelines:
53+
54+
- **Regular Review**: Review and update workflows at least quarterly to incorporate new features or best practices.
55+
- **Dependency Updates**: Keep workflow dependencies up-to-date by reviewing and applying Dependabot suggestions promptly.
56+
- **Documentation**: Update workflow documentation immediately after any changes or modifications to keep it current.
57+
- **Performance Monitoring**: Regularly check workflow run times and optimize where possible to reduce GitHub Actions usage.
58+
- **Security Checks**: Ensure that workflows using secrets or accessing sensitive data are properly secured and follow least privilege principles.
59+
60+
These guidelines aim to maintain the integrity and efficiency of our CI/CD processes. Always consult with the team before making significant changes to any workflow.

.github/workflows/pull-request.yml renamed to .github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: PR Workflow
1+
name: CI
22
on:
33
pull_request:
44
types: [opened, reopened, synchronize]
55

66
jobs:
7-
linting_and_type-checking:
8-
name: Linting, Formatting and Type checking
7+
code-quality-checks:
8+
name: Code Quality Checks
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout repository
@@ -44,8 +44,8 @@ jobs:
4444
- name: Type checking
4545
run: yarn run typecheck
4646

47-
Check-Unauthorized-File-Changes:
48-
name: Checks if no unauthorized files are changed
47+
check-unauthorized-file-changes:
48+
name: Check Unauthorized File Changes
4949
if: ${{github.actor != 'dependabot[bot]'}}
5050
runs-on: ubuntu-latest
5151
steps:
@@ -94,8 +94,8 @@ jobs:
9494
9595
build:
9696
name: Build check
97+
needs: code-quality-checks
9798
runs-on: ubuntu-latest
98-
needs: linting_and_type-checking
9999
steps:
100100
- name: Checkout repository
101101
uses: actions/checkout@v4

.github/workflows/issue.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ on:
55
types: ['opened']
66

77
jobs:
8-
Issue-Labeler:
9-
name: Adding Label to issue
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: Renato66/[email protected]
13-
with:
14-
repo-token: ${{ secrets.GITHUB_TOKEN }}
15-
ignore-comments: true
16-
default-labels: '["Status: Triage"]'
8+
issue-labeler:
9+
name: Adding Label to Issue
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Auto Label Issue
13+
uses: Renato66/[email protected]
14+
with:
15+
repo-token: ${{ secrets.GITHUB_TOKEN }}
16+
ignore-comments: true
17+
default-labels: '["Status: Triage"]'
1718

18-
Issue-Greeting:
19-
name: Greeting Message to User
20-
runs-on: ubuntu-latest
21-
steps:
22-
- name: Greeting Message to User
23-
uses: actions/first-interaction@v1
24-
with:
25-
repo-token: ${{ secrets.GITHUB_TOKEN }}
26-
issue-message: |
27-
Welcome to the [JSON Schema](https://json-schema.org/) Community. We are so excited you are here! Thanks a lot for reporting your first issue!! 🎉🎉 Please make sure to take a look to our [contributors guide](https://github.com/json-schema-org/website/blob/main/CONTRIBUTING.md) if you plan on opening a pull request.
28-
For more details check out [README.md](https://github.com/json-schema-org/website?tab=readme-ov-file#-welcome-to-the-json-schema-website) file.
29-
19+
issue-greeting:
20+
name: Greeting Message to User
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Send Greeting Message
24+
uses: actions/first-interaction@v1
25+
with:
26+
repo-token: ${{ secrets.GITHUB_TOKEN }}
27+
issue-message: |
28+
Welcome to the [JSON Schema](https://json-schema.org/) Community. We are so excited you are here! Thanks a lot for reporting your first issue!! 🎉🎉 Please make sure to take a look at our [contributors guide](https://github.com/json-schema-org/website/blob/main/CONTRIBUTING.md) if you plan on opening a pull request.
29+
For more details, check out the [README.md](https://github.com/json-schema-org/website?tab=readme-ov-file#-welcome-to-the-json-schema-website) file.

.github/workflows/links.yml renamed to .github/workflows/link-checker.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88

99
jobs:
1010
linkChecker:
11+
name: Check and Report Broken Links
1112
runs-on: ubuntu-latest
1213
steps:
1314
- name: Checkout Repository

.github/workflows/pull-request-target.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Pull Request Target Workflow
1+
name: PR Interaction Workflow
22

33
on:
44
pull_request_target:
File renamed without changes.

0 commit comments

Comments
 (0)