Skip to content

iahmedelbayaa/github-actions

Repository files navigation

TypeScript NodeJS Docker AWS Ubuntu GitHub Actions

GitHub Actions 🪐

Description ✍

This is a Express Rest API. I'm trying here to run a CI/CD pipeline starting from building the docker image till deploying the container to AWS EC2 Ubuntu instance every time I push updates to the Main branch. Here are the steps:

Continuous Integration (CI)

  • Checkout code.
  • Login to dockerhub.
  • Build docker image that contains the Express Rest API and tag it with the commit sha.
  • Push the docker image to dockerhub.

Continuous Deployment (CD) 🚀

  • Stop running docker containers.
  • Delete existing docker images.
  • Pull docker image that contains the Express Rest API.
  • Run docker container and expose port 3000.

Getting Started ▶️

Setup AWS EC2 Ubuntu Runner ⚙️

visit https://github.com/<username>/<repo-name>/settings/actions/runners
click "New self-hosted runner"
choose runner image & architecture from the options macOS, Linux and Windows.
follow the commands (with the normal user **"ubuntu"** and not the root user)

Setup AWS EC2 Ubuntu Runner Service ⚙️

# do the following (with the normal user **"ubuntu"** and not the root user) to enable the ec2 instance to listen to the jobs triggered by the workflow.
# micro is a terminal-text-editor, to install it, run this command "sudo apt install micro"
sudo micro /etc/systemd/system/github-runner.service

# Content of the file
[Unit]
Description=GitHub Actions Self-hosted Runner
After=network.target

[Service]
WorkingDirectory=/home/ubuntu/actions-runner
ExecStart=/home/ubuntu/actions-runner/run.sh
Restart=always
Environment="RUNNER_ALLOW_RUNASROOT=1"  # Add this line if required

[Install]
WantedBy=multi-user.target
# End of file's content

# then run
sudo systemctl enable github-runner
sudo systemctl start github-runner
sudo systemctl status github-runner.service

Contribution 🤝

If you're interested in contributing to this project, please follow these guidelines:

  1. Fork the repository
  2. Make your changes
  3. Submit a Pull Request

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published