{"id":19810224,"url":"https://github.com/mathiasreker/java-ci-cd","last_synced_at":"2025-05-01T08:31:49.172Z","repository":{"id":37092534,"uuid":"480489820","full_name":"MathiasReker/Java-CI-CD","owner":"MathiasReker","description":"This is an example of building a CI/CD pipeline using GitHub actions. :white_check_mark::octocat::whale2:","archived":false,"fork":false,"pushed_at":"2024-08-23T13:19:16.000Z","size":213,"stargazers_count":7,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2024-08-23T14:52:10.379Z","etag":null,"topics":["action","cd","ci","devops","github","java","jpa","maven","mysql","pipeline","spring","workflow"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MathiasReker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-04-11T17:49:33.000Z","updated_at":"2024-08-23T13:19:18.000Z","dependencies_parsed_at":"2023-02-12T02:46:19.513Z","dependency_job_id":"dc8a4ab9-5bf5-44ef-bd4e-59c7d243d901","html_url":"https://github.com/MathiasReker/Java-CI-CD","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathiasReker%2FJava-CI-CD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathiasReker%2FJava-CI-CD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathiasReker%2FJava-CI-CD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathiasReker%2FJava-CI-CD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MathiasReker","download_url":"https://codeload.github.com/MathiasReker/Java-CI-CD/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224246590,"owners_count":17279827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["action","cd","ci","devops","github","java","jpa","maven","mysql","pipeline","spring","workflow"],"created_at":"2024-11-12T09:20:04.458Z","updated_at":"2024-11-12T09:20:09.299Z","avatar_url":"https://github.com/MathiasReker.png","language":"Java","readme":"\u003cdiv id=\"top\"\u003e\u003c/div\u003e\n\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n[![CI/CD][cicd-shield]][cicd-url]\n\n\u003cdiv align=\"center\"\u003e\n\u003ch3\u003eCI/CD GitHub Action :rocket:\u003c/h3\u003e\n  \u003cp\u003e\n    A CI/CD workflow for your maven project!\n  \u003c/p\u003e\n\u003c/div\u003e\n\n## Getting Started\n\nThis is an example of building a CI \u0026 CD pipeline using GitHub actions.\n\nThe CI pipeline depends on maven to compile and test the project's code. JPA/MySQL is supported.\n\nThe CD pipeline will create a docker image of the project's code and deploy the image as a docker container along with a\nMySQL container on a remote server using SSH. The bridge driver of docker networks connects these containers.\n\nIn the `docker-compose.yml`, you can configure the tag of the images. By default, the tag of the project is `dev`.\nHowever, you can change the tag to a specific version to control the deployment. The workflow supports tags in the\nsem-version format like `v*.*.*`.\n\nTo create a new release using a specific tag, navigate to your GitHub repository. Go to tags -\u003e create new release -\u003e\npublish the release.\n\n### Prepare the production server\n\n1. Connect to your server\n   ```sh\n   ssh -i \u003cprivate key path\u003e \u003cuser\u003e@\u003chost\u003e\n   ```\n\n2. Add environment variables\n   ```sh\n   echo \"MYSQL_ROOT_PASSWORD=myrootpw\n   MYSQL_DATABASE=mydb\n   MYSQL_USER=myuser\n   MYSQL_PASSWORD=mypw\n   DOCKER_IMAGE_NAME=ci-cd\n   GITHUB_USER=mathiasreker\" \u003e~/.env\n   ```\n\n   _`MYSQL_ROOT_PASSWORD`, `MYSQL_DATABASE`, `MYSQL_USER` and `MYSQL_PASSWORD` can be anything._\n\n   _`DOCKER_IMAGE_NAME` must match the name of the docker image defined\n   in [workflow](https://github.com/MathiasReker/CI-CD/blob/develop/.github/workflows/ci-cd.yml)._\n\n   _`GITHUB_USER` must be the user/organisation of the repository in **lower case**._\n\n\u003e _This script replaces step 3-6 (optional)_\n\u003e ```sh\n\u003e bash \u003c(curl -s https://raw.githubusercontent.com/MathiasReker/Java-CI-CD/develop/install.bash)\n\u003e ```\n\n3. Install docker-compose\n   ```sh\n   sudo apt-get update \u0026\u0026 sudo apt-get install -y docker-compose\n   ```\n\n4. Generate a new key named `github-actions` with an empty password\n   ```sh\n   ssh-keygen -t rsa -b 4096 -f ~/.ssh/github-actions -q -P \"\"\n   ```\n\n5. Copy the content of `github-actions` into `authorized_keys`\n   ```sh\n   cat ~/.ssh/github-actions.pub \u003e\u003e~/.ssh/authorized_keys\n   ```\n\n6. Grab the private key, as you will need it soon\n   ```sh\n   cat ~/.ssh/github-actions\n   ```\n\n### Install action secrets\n\nNavigate to your GitHub repository. Go to settings -\u003e secrets -\u003e actions.\n\nAdd the following secrets:\n\n- SSH_USER\n- SSH_HOST\n- SSH_PRIVATE_KEY\n\n### Install the workflow to your project\n\n1. Copy the [workflow](https://github.com/MathiasReker/CI-CD/blob/develop/.github/workflows/ci-cd.yml) to this path of\n   your repository: `/.github/workflows/ci-cd.yml`.\n\n2. Copy the [docker-compose.yml](https://github.com/MathiasReker/CI-CD/blob/develop/docker-compose.yml) to the root\n   folder of your project.\n\n3. Copy the [Dockerfile](https://github.com/MathiasReker/CI-CD/blob/develop/Dockerfile) to the root folder of your\n   project.\n\n_Depending on your project, it is necessary to adapt the `docker-compose.yml` and the `Dockerfile`._\n\n### Package visibility\n\nTo see the package, the CD pipeline must run at least once. The pipeline will create a package linked to your GitHub\nrepository.\n\nNavigate to your GitHub repository. Go to the package -\u003e select package settings -\u003e select danger zone -\u003e change\nvisibility -\u003e make it public.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n## Usage\n\nThe CI pipeline is triggered on any change to the code on your repository.\n\nThe CD pipeline is triggered on push events. The CD pipeline will be skipped if the CI pipeline fails.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n## Roadmap\n\n- [x] CI workflow\n- [x] CD workflow\n- [x] Unit test\n- [x] Integration test using JPA\n\nSee the [open issues](https://github.com/MathiasReker/CI-CD/issues) for a complete list of proposed features (and known\nissues).\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n## Contributing\n\nIf you have a suggestion to improve this, please fork the repo and create a pull request. You can also open an issue\nwith the tag \"enhancement\". Finally, don't forget to give the project a star! Thanks again!\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n## License\n\nIt is distributed under the MIT License. See `LICENSE` for more information.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n[contributors-shield]: https://img.shields.io/github/contributors/MathiasReker/CI-CD.svg\n\n[contributors-url]: https://github.com/MathiasReker/CI-CD/graphs/contributors\n\n[forks-shield]: https://img.shields.io/github/forks/MathiasReker/CI-CD.svg\n\n[forks-url]: https://github.com/MathiasReker/CI-CD/network/members\n\n[stars-shield]: https://img.shields.io/github/stars/MathiasReker/CI-CD.svg\n\n[stars-url]: https://github.com/MathiasReker/CI-CD/stargazers\n\n[issues-shield]: https://img.shields.io/github/issues/MathiasReker/CI-CD.svg\n\n[issues-url]: https://github.com/MathiasReker/CI-CD/issues\n\n[license-shield]: https://img.shields.io/github/license/MathiasReker/CI-CD.svg\n\n[license-url]: https://github.com/MathiasReker/CI-CD/blob/master/LICENSE.txt\n\n[cicd-shield]: https://github.com/MathiasReker/CI-CD/actions/workflows/ci-cd.yml/badge.svg?branch=develop\n\n[cicd-url]: https://github.com/MathiasReker/CI-CD/actions/workflows/ci-cd.yml\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathiasreker%2Fjava-ci-cd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathiasreker%2Fjava-ci-cd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathiasreker%2Fjava-ci-cd/lists"}