Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DevOps Docs #57

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/devops/Automation/10bedicu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## `update_json.yml`

The `update_json.yml` workflow performs the following tasks:

1. **Run Scraper Scripts**:
- Executes the scraper scripts stored in the `scraper` directory.

2. **Update JSON Files**:
- Updates the JSON files located in the `data` directory:
- `donors.json`
- `hospital_status.json`
- `hospitals.json`
- `meta.json`
- `pmu.json`

3. **Update Interval**:
- The JSON files are updated at specified intervals or manually.

4. **Reflect Changes**:
- Ensures that the updates are reflected on the 10bedICU website.

---
21 changes: 21 additions & 0 deletions docs/devops/Automation/admission_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## `makefile.yml`

The `makefile.yml` workflow consists of the following steps:

1. **Check Out Code**:
- Checks out the code from the repository.

2. **Build Packages**:
- Builds language-specific packages using the `make` command.

3. **Configure Git**:
- Configures Git with a bot user's credentials.

4. **Commit Changes**:
- Commits any modifications with the message `"Add submission report"` if there are changes.

5. **Push Changes**:
- Pushes the committed changes back to the `main` branch.
- Uses the `ad-m/github-push-action` with a GitHub token for authentication.

---
73 changes: 73 additions & 0 deletions docs/devops/Automation/arike.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

## `main.yml`

The `main.yml` workflow consists of the following steps:

1. **Check Out Code**: Checks out the repository's code.
2. **Check for Docker Compose File**:
- If `docker-compose.test.yml` is present, it builds and runs tests using Docker Compose.
- If the file is not present, it builds the Docker image using a Dockerfile.
3. **Environment Variable**: `IMAGE_NAME` is set to `arike-main`, though it is not explicitly used in the workflow.

---

## `Production.yml`

The `Production.yml` workflow is composed of three main jobs:

### Test Job

1. **Check Out Code**: Checks out the code from the repository.
2. **Run Tests**:
- Uses Docker Compose if `docker-compose.test.yml` is found.
- Falls back to a Docker build using a Dockerfile if the Docker Compose file is not present.

### Push Job

1. **Build Docker Image**: Builds the Docker image tagged with the `IMAGE_NAME` environment variable.
2. **Log In to Docker Registry**: Logs into the Docker registry.
3. **Push Docker Image**: Pushes the Docker image to the registry.
4. **Create Version Tags**:
- Tags the image based on the Git reference.
- Handles both tag and branch names appropriately.
- Pushes all tags to the registry.

### Deploy Job

1. **Deploy Docker Image**: Deploys the Docker image to a remote server using SSH.
2. **Manage Existing Container**:
- Stops and removes the existing Docker container.
- Pulls the new image.
- Runs the new Docker container with specified environment variables.
3. **Restart Nginx**: Restarts Nginx on the server to apply the changes.

---

## `staging.yml`

The `staging.yml` workflow is triggered by pushes and pull requests to the `staging` branch. It operates in an Ubuntu environment and includes three main jobs:

### Test Job

1. **Check Out Code**: Checks out the code from the repository.
2. **Build and Test**:
- Uses Docker Compose if `docker-compose.test.yml` is present.
- Falls back to a Docker build using a Dockerfile if the Docker Compose file is not present.

### Push Job

1. **Build Docker Image**: Builds the Docker image with the tag specified in the `IMAGE_NAME` environment variable.
2. **Log In to Docker Registry**: Logs into the Docker registry using a GitHub token.
3. **Push Docker Image**: Pushes the Docker image to the registry.
4. **Tag Image**: Tags the image with both the version extracted from the Git reference and a `latest` tag if applicable.

### Deploy Job

1. **Deploy Docker Image**: Deploys the Docker image to a staging server via SSH.
2. **Manage Staging Container**:
- Stops and removes the existing staging container.
- Pulls the new image.
- Runs the new Docker container with environment variables specified in a file.
3. **Restart Nginx**: Restarts Nginx on the server to apply the changes.

---
24 changes: 24 additions & 0 deletions docs/devops/Automation/awareness.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## `test.yml`

The `test.yml` workflow performs the following tasks:

1. **Checkout Code**:
- Uses the `actions/checkout@v2` action to check out the repository code.

2. **Setup Node.js**:
- Uses the `actions/setup-node@v1` action to set up Node.js.

3. **Install Dependencies**:
- Runs `npm ci` to install project dependencies.

4. **Build Project**:
- Runs `npm run re:build` and `npm run build` to build the project.

5. **Run Tests**:
- Executes `npm test` to run the project tests with the `CI` environment variable set to `true`.

6. **Trigger Events**:
- The workflow is triggered on push events and pull requests.


---
86 changes: 86 additions & 0 deletions docs/devops/Automation/ayushma.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
## `deployment.yaml`

The `deployment.yaml` workflow performs the following tasks:

1. **Trigger Events**:
- The workflow is triggered by manual dispatch or pushes to the `master` and `production` branches.

2. **Checkout Code**:
- Uses `actions/checkout` to retrieve the code from the repository.

3. **Generate Docker Metadata**:
- Uses `docker/metadata-action` to generate Docker image metadata and tags based on the Git reference and run number, with specific tags for the `production` branch.

4. **Set Up Docker Buildx**:
- Configures Docker Buildx for extended build capabilities.

5. **Cache Docker Layers**:
- Uses `actions/cache` to cache Docker layers, speeding up subsequent builds.

6. **Login to Registries**:
- Logs into DockerHub and GitHub Container Registry using credentials from secrets.

7. **Build and Push Docker Image**:
- Uses `docker/build-push-action` to build the Docker image and push it to the specified registries with the previously defined tags.

8. **Update Docker Cache**:
- Manages the Docker cache by moving the new cache directory to replace the old one.

---

## `linter.yaml`

The `linter.yaml` workflow performs the following tasks:

1. **Trigger Events**:
- The workflow is triggered by pull requests targeting the `master` branch.

2. **Checkout Code**:
- Uses `actions/checkout` to fetch the repository's code with full history (`fetch-depth: 0`).

3. **Lint Code Base**:
- Runs `super-linter` with configurations for Python linters such as `black`, `flake8`, and `isort`, based on settings in `setup.cfg` and `pyproject.toml`.
- The linter runs with `DEFAULT_BRANCH` set to `master`, and the `GITHUB_TOKEN` is provided for GitHub authentication.

This workflow ensures that the codebase is linted according to the specified rules and configurations before merging pull requests into the `master` branch.

---

## `test-base.yaml`

The `test-base.yaml` workflow performs the following tasks:

1. **Checkout Code**:
- Uses `actions/checkout` to retrieve the repository's code.

2. **Set Up Docker Buildx**:
- Configures Docker Buildx using `docker/setup-buildx-action` for advanced build capabilities.

3. **Cache Docker Layers**:
- Caches Docker build layers using `actions/cache`, with a cache key based on `Pipfile.lock` and Dockerfile, and restore keys for fallback.

4. **Bake Docker Images**:
- Builds Docker images using `docker/bake-action`, reading configuration from `docker-compose.local.yaml` and optimizing build times with layer caching.

5. **Start Services**:
- Uses Docker Compose to start services defined in `docker-compose.local.yaml`, waiting for them to be fully operational.

6. **Check Migrations**:
- Runs `make checkmigration` to verify database migrations.

7. **Move Cache**:
- Updates the Docker build cache by moving the new cache directory to replace the old one.

---

## `test.yaml`

The `test.yaml` workflow performs the following tasks:

1. **Trigger Events**:
- The workflow is triggered by pull request events.

2. **Use Reusable Workflow**:
- Includes a single job named `test` that utilizes a reusable workflow defined in `./.github/workflows/test-base.yaml`.

This setup allows the "Test PR" workflow to leverage the configurations and steps defined in the `test-base.yaml` file, ensuring consistency and efficiency across different workflows.
32 changes: 32 additions & 0 deletions docs/devops/Automation/ayushma_fe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## `deploy.yml`

The `deploy.yml` workflow performs the following tasks:

1. **Trigger Events**:
- The workflow is triggered by manual dispatch or pushes to the `production` branch.

2. **Checkout Code**:
- Uses `actions/checkout@v3` to retrieve the repository's code.

3. **Generate Docker Metadata**:
- Utilizes `docker/metadata-action@v4` to generate metadata and tags for the Docker image, including versioning based on the GitHub run number and semantic versioning patterns.

4. **Set Up Docker Buildx**:
- Configures Docker Buildx with `docker/setup-buildx-action@v2` to enable advanced build capabilities.

5. **Cache Docker Layers**:
- Caches Docker layers using `actions/cache@v3` to speed up build times. The cache key is based on `package.json` and the Dockerfile.

6. **Login to Docker Registries**:
- Logs into DockerHub and GitHub Container Registry using `docker/login-action@v2`, with credentials provided via secrets.

7. **Run `pnpm`**:
- Installs project dependencies using `pnpm`.

8. **Build and Push Docker Image**:
- Uses `docker/build-push-action@v4` to build and push the Docker image, with caching for build layers and tagging as defined by the earlier metadata step.

9. **Update Cache**:
- Manages the Docker build cache by replacing the old cache directory with the new one.

---
19 changes: 19 additions & 0 deletions docs/devops/Automation/bot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## `workflow.yml`

The `workflow.yml` workflow consists of the following tasks:

1. **Trigger Events**:
- The workflow is triggered by push or pull request events to the `master` branch.

2. **Checkout Code**:
- Uses `actions/checkout@v2` to check out the repository code, making it available for subsequent steps.

3. **Login to Heroku Container Registry**:
- Logs into the Heroku Container Registry using the `heroku container:login` command. The Heroku API key is provided via the `HEROKU_API_KEY` secret.

4. **Build and Push Container**:
- Builds and pushes the Docker container to Heroku with the `heroku container:push` command, targeting the `web` process type for the `ohcnetwork-bot` app.

5. **Release Container**:
- Releases the Docker container to the Heroku app using the `heroku container:release` command, making the updated container live.
---
34 changes: 34 additions & 0 deletions docs/devops/Automation/care-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## `deploy.yml`

The `deploy.yml` workflow performs the following tasks:

1. **Trigger Events**:
- The workflow is triggered either manually via workflow dispatch or automatically by pushes to the `master` branch.

2. **Job `build-staging`**:
- **Condition**: Runs only if the Git reference is `refs/heads/master`, ensuring it only executes for the `master` branch.
- **Environment**: Runs on the latest Ubuntu environment.

**Steps**:
1. **Checkout Code**:
- Uses `actions/checkout@v3` to check out the repository code.

2. **Generate Docker Metadata**:
- Uses `docker/metadata-action@v4` to generate Docker image metadata and tags. The tags include versions based on the GitHub run number and semantic versioning patterns.

3. **Set Up Docker Buildx**:
- Configures Docker Buildx with `docker/setup-buildx-action@v2` for advanced build capabilities.

4. **Cache Docker Layers**:
- Uses `actions/cache@v2` to cache Docker layers and speed up builds. The cache is based on `requirements.txt` and `Dockerfile`.

5. **Login to GitHub Container Registry**:
- Logs into GitHub Container Registry (`ghcr.io`) using `docker/login-action@v2` with credentials from secrets.

6. **Build and Push Docker Image**:
- Builds and pushes the Docker image using `docker/build-push-action@v3`, applying tags from the metadata step and leveraging the cache for efficiency.

7. **Update Cache**:
- Manages Docker build cache by replacing the old cache with the new one.

This workflow ensures that Docker images are built and pushed with appropriate tags, optimizing the build process with caching and updating the container registry as specified.
Loading