{"id":23122333,"url":"https://github.com/andrecaiado/spring-boot-tests-cicd","last_synced_at":"2026-04-08T21:31:18.544Z","repository":{"id":224055642,"uuid":"757408637","full_name":"andrecaiado/spring-boot-tests-cicd","owner":"andrecaiado","description":"Spring Boot application with tests and CI/CD workflow","archived":false,"fork":false,"pushed_at":"2024-04-04T14:54:30.000Z","size":1336,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T04:15:04.160Z","etag":null,"topics":["aws","aws-ec2","cicd","docker","jacoco","postgresql","spring-boot","testing","workflow"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrecaiado.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-14T12:42:37.000Z","updated_at":"2024-08-19T14:29:48.000Z","dependencies_parsed_at":"2024-12-17T07:19:27.864Z","dependency_job_id":"feae5801-823c-44bb-9e02-d91e7f676c02","html_url":"https://github.com/andrecaiado/spring-boot-tests-cicd","commit_stats":null,"previous_names":["andrecaiado/spring-boot-unit-test-rest-controller"],"tags_count":40,"template":false,"template_full_name":null,"purl":"pkg:github/andrecaiado/spring-boot-tests-cicd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrecaiado%2Fspring-boot-tests-cicd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrecaiado%2Fspring-boot-tests-cicd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrecaiado%2Fspring-boot-tests-cicd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrecaiado%2Fspring-boot-tests-cicd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrecaiado","download_url":"https://codeload.github.com/andrecaiado/spring-boot-tests-cicd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrecaiado%2Fspring-boot-tests-cicd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31575392,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-ec2","cicd","docker","jacoco","postgresql","spring-boot","testing","workflow"],"created_at":"2024-12-17T07:18:47.691Z","updated_at":"2026-04-08T21:31:18.528Z","avatar_url":"https://github.com/andrecaiado.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring Boot application with tests and CI/CD workflow\n\nThe main purpose of this repository is to demonstrate how to set up a CI/CD workflow using GitHub Actions.\n\nThe application used is a simple Spring Boot application with a REST controller and a test class.\n\n## Workflows\n\nThere are two workflows in this repository:\n- [Validate PR](#validate-pr)\n- [CI-CD](#ci-cd)\n\n### Validate PR\n\nThis workflow validates the pull request title. \n\nIt uses an action from [amannn/action-semantic-pull-request](https://github.com/amannn/action-semantic-pull-request) to check if the pull request title follows the semantic versioning pattern.\n\nThe workflow is triggered when a pull request is opened, edited or synchronized.\n\nThe workflow file is located at [.github/workflows/validate-pr.yml`](.github/workflows/validate-pr.yml).\n\n### CI-CD\n\nThis workflow is responsible for:\n - Building and testing the application.\n - Building a Docker image and pushing it to Docker Hub.\n - Deploying the application to an environment.\n\nThe workflow is triggered when one of the following events occurs:\n- A Pull Request is opened, synchronized, reopened or closed.\n- A commit is pushed to a Pull Request.\n- A Pull Request is merged to the branch `main`.\n- A new release is published.\n\nThe workflow file is located at [.github/workflows/ci-cd.yml](.github/workflows/ci-cd.yml).\n\nThe workflow is divided into the following jobs:\n\n![workflows.png](src%2Fmain%2Fresources%2Fworkflows.png)\n\n#### Prepare\n\n![prepare.png](src%2Fmain%2Fresources%2Fprepare.png)\n\n#### Build and test\n\n![build-and-test.png](src%2Fmain%2Fresources%2Fbuild-and-test.png)\n\nThe code coverage is executed with JaCoCo maven plugin and the report is generated with [JaCoCo Report](https://github.com/marketplace/actions/jacoco-report).\n\n#### Build image and push\n\n![build-image-and-push.png](src%2Fmain%2Fresources%2Fbuild-image-push.png)\n\n#### Deploy\n\nThe application is deployed in an AWS EC2 instance using SSH.\n\nIn order to authenticate the SSH connection, a private key is needed and so, it was created in AWS and stored as a secret in the repository.\nThe secrets used in the workflow are:\n- `DOCKER_USERNAME` and `DOCKER_PASSWORD` to authenticate in Docker Hub.\n- `AWS_EC2_USERNAME`, `AWS_EC2_IPADDRESS` and `AWS_EC2_PRIVATE_KEY` to connect to the EC2 instance.\n\n__Note:__ Each time the instance is stopped and started, the EC2 instance public IP address changes and we need to update the `AWS_EC2_IPADDRESS` secret. To avoid this, an Elastic IP could have been used but for now, it was not implemented.\n\nThe deploy job has the following steps:\n- Login to Docker Hub.\n- Sets permissions to the private key file that is going to be used to authenticate SSH connection.\n- The following steps are then executed inside the EC2 instance (connected via SSH):\n  - Pull the new image.\n  - Stop the running container (by container name).\n  - Remove the container (by container name).\n  - Run the new container.\n\nContainers are named with the following pattern: `spring-boot-tests-cicd-\u003cenvironment\u003e`.\n\n![containers.png](src%2Fmain%2Fresources%2Fcontainers.png)\n\nThe environment variable value is added to the container as an environment variable in the `run` command. It can be `STAGING` or `PRODUCTION`.\n\nThe application will load the environment variable and use the value in the `/api/greeting` endpoint to present a message with the environment name.\n\n![hello-stag.png](src%2Fmain%2Fresources%2Fhello-stag.png)\n![hello-prod.png](src%2Fmain%2Fresources%2Fhello-prod.png)\n\nThe application port is set to `8080` and the container port is mapped to the host port `8080` for the STAGING environment and `8081` for the PRODUCTION environment.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrecaiado%2Fspring-boot-tests-cicd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrecaiado%2Fspring-boot-tests-cicd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrecaiado%2Fspring-boot-tests-cicd/lists"}