This repository uses GitHub Actions to automate the Continuous Integration (CI) process. Below are the steps to set up the CI workflow.
-
Create the GitHub Actions Workflow Directory
In your repository, create a directory structure for GitHub Actions workflows:
mkdir -p .github/workflows
-
Create the CI Workflow File
Inside the
.github/workflows
directory, create a YAML file namedci.yml
.touch .github/workflows/ci.yml
-
Define the Workflow
Add the following content to the
ci.yml
file:name: CI for Security Tracker on: push: branches: [ main ] pull_request: branches: [ main ] jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up Node.js uses: actions/setup-node@v2 with: node-version: 'lts/*' - name: Install dependencies run: npm install - name: Run app.js run: node app.js
-
Stage, Commit, and Push Changes
Stage, commit, and push your changes to the
main
branch:git add .github/workflows/ci.yml git commit -m "Add CI workflow with latest Node.js LTS" git push origin main
-
Verify the Workflow
- Go to your repository on GitHub.
- Click on the
Actions
tab to see the workflow running.
- name: The name of the workflow.
- on: Specifies the events that trigger the workflow. It runs on pushes and pull requests to the
main
branch. - jobs: Defines the jobs to be run.
- runs-on: Specifies the type of machine to run the job on (e.g.,
ubuntu-latest
). - steps: The series of steps to be executed in the job:
- Checkout code: Uses
actions/checkout@v2
to check out your repository's code. - Set up Node.js: Uses
actions/setup-node@v2
to set up a Node.js environment with the latest LTS version. - Install dependencies: Runs
npm install
to install npm dependencies. - Run app.js: Runs your
app.js
file with thenode app.js
command.
- Checkout code: Uses
- For more details on GitHub Actions, refer to the GitHub Actions Documentation.
- If you encounter any issues, ensure your YAML syntax is correct and check the GitHub Actions tab for detailed logs and errors.
By following these steps, you will set up a GitHub Actions workflow that uses the latest LTS version of Node.js, installs necessary npm modules, and runs your app.js
file on each push or pull request to the main
branch.