JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Gallery
Share
Explore
Lab: Setting Up and Using GitHub Issues and GitHub Actions for CI/CD
More elaborated worksteps:
https://coda.io/@peter-sigurdson/more-detailed-worksteps-for-the-ci-cd-setup-lab
Lab: Setting Up and Using GitHub Issues and GitHub Actions for CI/CD
This lab guides students through:
- creating a GitHub repository
setting up GitHub Actions for Continuous Integration (CI)
managing GitHub Issues to simulate practical DevOps workflows
Objectives
Create a GitHub repository and upload a
TypeScript code base
.
Set up a basic GitHub Actions workflow to automate builds and tests.
Use GitHub Issues to track and resolve issues, simulating Agile DevOps practices.
Prerequisites
A GitHub account.
Basic knowledge of TypeScript.
A completed codebase from a previous assignment.
Part 1: GitHub Repository Setup and Code Upload
Create a New GitHub Repository
Go to
GitHub
and log in.
Click on the
New
button to create a new repository.
Name the repository (e.g.,
devops-pipeline-lab
), add a description, and make it
Public
or
Private
as needed.
Check the box
to initialize with a README (optional).
Click
Create repository
.
Upload Your Code
Clone the Repository
:
git clone <your-repository-URL>
Copy your TypeScript code files from Assignment 1 into this repository folder.
Push the Code to GitHub
:
bash
Copy code
git add .
git commit -m "Initial code upload"
git push origin main
Verify that the code is now in your GitHub repository by refreshing the repository page.
Validate
: Confirm that all files are present in the repository and that no errors occurred during the upload.
Part 2: Setting Up GitHub Actions for CI/CD
Navigate to GitHub Actions
In your repository, click on the
Actions
tab.
Select
Set up a workflow yourself
.
Create a Workflow File
Name the file
.github/workflows/ci.yml
.
Copy the following YAML configuration for basic CI/CD automation:
yaml
Copy code
name: CI Pipeline
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: '16'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
- name: Lint code
run: npm run lint
Save
the file to initiate the workflow setup.
Configure Your Project’s Scripts
In your
package.json
, ensure you have the following scripts for testing and linting:
json
Copy code
"scripts": {
"test": "jest",
"lint": "eslint ."
}
Validate
: Push changes and confirm that the GitHub Action triggers automatically. View the
Actions
tab to check if the workflow passed.
Part 3: Managing Issues on GitHub
Creating GitHub Issues
Navigate to the
Issues
tab in your repository.
Click on
New issue
to create an issue.
Title the issue (e.g., “Fix broken tests” or “Implement Docker setup”).
Add a detailed description, including the expected behavior, any observed issues, and potential solutions.
Assign
the issue to yourself or a team member.
Label
the issue appropriately (e.g.,
bug
,
enhancement
,
documentation
).
Linking Issues to Commits and Pull Requests
When working on an issue, create a new branch with the issue name:
bash
Copy code
git checkout -b issue-<issue-number>
Make the necessary code changes.
Commit changes
with a message referencing the issue:
bash
Copy code
git commit -m "Fixes #<issue-number>: Description of the fix"
Push the branch
and open a Pull Request (PR) on GitHub, linking it to the issue.
Tracking and Resolving Issues
In the
Pull Request
page, request a review if working in teams.
Once approved, merge the PR, which automatically closes the linked issue.
Validate
: Confirm the issue is closed, and the code changes are visible on the main branch.
Part 4: Expanding the Pipeline with Docker Integration (Optional)
Create a Dockerfile
In the root of your repository, add a
Dockerfile
:
dockerfile
Copy code
FROM node:16
WORKDIR /app
COPY . .
RUN npm install
CMD ["npm", "start"]
Update the GitHub Actions Workflow
Modify your
ci.yml
to include Docker build steps:
yaml
Copy code
- name: Build Docker Image
run: docker build -t myapp:latest .
Validate
: Ensure the Docker image builds successfully on GitHub Actions.
Part 5: Documenting the Workflow and Final Report
Create a Traceability Matrix
Use a simple table (e.g., in a markdown file) to link issues, code changes, and tests.
Write the README and Documentation
Include instructions for:
Setting up the project locally.
Running tests and linting.
Using GitHub Actions.
Final Validation
: Review all documentation and ensure all elements of the pipeline work as expected.
Submission Checklist
GitHub repository with CI/CD pipeline, Docker configuration, and Jest tests.
Documentation with a traceability matrix, README, and issue logs.
Confirmation of automated testing and issue tracking setup.
This lab exercises fundamental DevOps principles, guiding students to automate, document, and manage software in a streamlined, hands-on environment.
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
Ctrl
P
) instead.