Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
79 changes: 79 additions & 0 deletions .github/workflows/content-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Build and Push Content Service Image

on:
push:
tags:
- '*'

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the code
- name: Checkout code
uses: actions/checkout@v2

# Step 2: Set up JDK 11 and Maven
- name: Set up JDK 11 and Maven
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'

# Step 3: Build the project
- name: Build Content Service
run: |
mvn clean install -DskipTests=true \
-DCLOUD_STORE_GROUP_ID=${{ vars.CLOUD_STORE_GROUP_ID }} \
-DCLOUD_STORE_ARTIFACT_ID=${{ vars.CLOUD_STORE_ARTIFACT_ID }} \
-DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }}

# Step 4: Package the project
- name: Package Content Service
run: |
cd content-api
Copy link

Copilot AI May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The directory name 'content-api' differs from the packaging target 'content-service'; aligning these names may improve maintainability.

Suggested change
cd content-api
cd content-service

Copilot uses AI. Check for mistakes.
mvn play2:dist -pl content-service \
-DCLOUD_STORE_GROUP_ID=${{ vars.CLOUD_STORE_GROUP_ID }} \
-DCLOUD_STORE_ARTIFACT_ID=${{ vars.CLOUD_STORE_ARTIFACT_ID }} \
-DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }}

# Step 5: Set up Login to Docker registry
- name: Determine registry and login
run: |
if [[ -n "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}" ]]; then
echo "Using Google Container Registry"
echo "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}" | base64 --decode > $HOME/gcloud-key.json
gcloud auth activate-service-account --key-file=$HOME/gcloud-key.json
gcloud auth configure-docker ${{ secrets.REGISTRY_NAME }}
REGISTRY_URL=$(echo "${{ secrets.REGISTRY_URL }}" | tr '[:upper:]' '[:lower:]')

elif [[ -n "${{ secrets.REGISTRY_USERNAME }}" && -n "${{ secrets.REGISTRY_PASSWORD }}" ]]; then
echo "Logging in to custom Docker registry"
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ secrets.REGISTRY_NAME }} \
--username ${{ secrets.REGISTRY_USERNAME }} --password-stdin
REGISTRY_URL=$(echo "${{ secrets.REGISTRY_URL }}" | tr '[:upper:]' '[:lower:]')

else
echo "Using GitHub Container Registry (GHCR)"
REPO_NAME_LOWERCASE=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
REGISTRY_URL="ghcr.io/$REPO_NAME_LOWERCASE"
fi

echo "REGISTRY_URL=${REGISTRY_URL}" >> $GITHUB_ENV

# Step 6: Build Docker image
- name: Build Docker Image
run: |
IMAGE_NAME="content-service"
IMAGE_TAG=$(echo "${{ github.ref_name }}_$(echo $GITHUB_SHA | cut -c1-7)" | tr '[:upper:]' '[:lower:]')
docker build -f build/content-service/Dockerfile -t $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG} .

echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV

- name: Push Docker Image
run: |
docker push $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG}
80 changes: 80 additions & 0 deletions .github/workflows/search-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Build and Push Search Service Image

on:
push:
tags:
- '*'

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the code
- name: Checkout code
uses: actions/checkout@v2

# Step 2: Set up JDK 11 and Maven
- name: Set up JDK 11 and Maven
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'

# Step 4: Build the project
- name: Build Search API Service
run: |
mvn clean install -DskipTests=true \
-DCLOUD_STORE_GROUP_ID=${{ vars.CLOUD_STORE_GROUP_ID }} \
-DCLOUD_STORE_ARTIFACT_ID=${{ vars.CLOUD_STORE_ARTIFACT_ID }} \
-DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }}

# Step 5: Package the project
- name: Package Search API Service
run: |
cd search-api
Copy link

Copilot AI May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The directory name 'search-api' differs from the packaging target 'search-service'; consider aligning these names for clarity.

Suggested change
cd search-api
cd search-service

Copilot uses AI. Check for mistakes.
mvn play2:dist -pl search-service \
-DCLOUD_STORE_GROUP_ID=${{ vars.CLOUD_STORE_GROUP_ID }} \
-DCLOUD_STORE_ARTIFACT_ID=${{ vars.CLOUD_STORE_ARTIFACT_ID }} \
-DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }}

# Step 6: Set up Login to Docker registry
- name: Determine registry and login
run: |
if [[ -n "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}" ]]; then
echo "Using Google Container Registry"
echo "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}" | base64 --decode > $HOME/gcloud-key.json
gcloud auth activate-service-account --key-file=$HOME/gcloud-key.json
gcloud auth configure-docker ${{ secrets.REGISTRY_NAME }}
REGISTRY_URL=$(echo "${{ secrets.REGISTRY_URL }}" | tr '[:upper:]' '[:lower:]')

elif [[ -n "${{ secrets.REGISTRY_USERNAME }}" && -n "${{ secrets.REGISTRY_PASSWORD }}" ]]; then
echo "Logging in to custom Docker registry"
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ secrets.REGISTRY_NAME }} \
--username ${{ secrets.REGISTRY_USERNAME }} --password-stdin
REGISTRY_URL=$(echo "${{ secrets.REGISTRY_URL }}" | tr '[:upper:]' '[:lower:]')

else
echo "Using GitHub Container Registry (GHCR)"
REPO_NAME_LOWERCASE=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
REGISTRY_URL="ghcr.io/$REPO_NAME_LOWERCASE"
fi

echo "REGISTRY_URL=${REGISTRY_URL}" >> $GITHUB_ENV

# Step 7: Build Docker image
- name: Build Docker Image
run: |
IMAGE_NAME="search-api"
IMAGE_TAG=$(echo "${{ github.ref_name }}_$(echo $GITHUB_SHA | cut -c1-7)" | tr '[:upper:]' '[:lower:]')
docker build -f build/search-service/Dockerfile -t $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG} .

echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV

# Step 8: Push Docker Image
- name: Push Docker Image
run: |
docker push $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG}
80 changes: 80 additions & 0 deletions .github/workflows/taxonomy-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Build and Push Taxonomy Service Image

on:
push:
tags:
- '*'

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the code
- name: Checkout code
uses: actions/checkout@v2

# Step 2: Set up JDK 11 and Maven
- name: Set up JDK 11 and Maven
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'

# Step 4: Build the project
- name: Build Taxonomy API Service
run: |
mvn clean install -DskipTests=true \
-DCLOUD_STORE_GROUP_ID=${{ vars.CLOUD_STORE_GROUP_ID }} \
-DCLOUD_STORE_ARTIFACT_ID=${{ vars.CLOUD_STORE_ARTIFACT_ID }} \
-DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }}

# Step 5: Package the project
- name: Package Taxonomy API Service
run: |
cd taxonomy-api
Copy link

Copilot AI May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The directory name 'taxonomy-api' differs from the packaging target 'taxonomy-service'; consider aligning these names to reduce confusion.

Suggested change
cd taxonomy-api
cd taxonomy-service

Copilot uses AI. Check for mistakes.
mvn play2:dist -pl taxonomy-service \
-DCLOUD_STORE_GROUP_ID=${{ vars.CLOUD_STORE_GROUP_ID }} \
-DCLOUD_STORE_ARTIFACT_ID=${{ vars.CLOUD_STORE_ARTIFACT_ID }} \
-DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }}

# Step 6: Set up Login to Docker registry
- name: Determine registry and login
run: |
if [[ -n "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}" ]]; then
echo "Using Google Container Registry"
echo "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}" | base64 --decode > $HOME/gcloud-key.json
gcloud auth activate-service-account --key-file=$HOME/gcloud-key.json
gcloud auth configure-docker ${{ secrets.REGISTRY_NAME }}
REGISTRY_URL=$(echo "${{ secrets.REGISTRY_URL }}" | tr '[:upper:]' '[:lower:]')

elif [[ -n "${{ secrets.REGISTRY_USERNAME }}" && -n "${{ secrets.REGISTRY_PASSWORD }}" ]]; then
echo "Logging in to custom Docker registry"
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ secrets.REGISTRY_NAME }} \
--username ${{ secrets.REGISTRY_USERNAME }} --password-stdin
REGISTRY_URL=$(echo "${{ secrets.REGISTRY_URL }}" | tr '[:upper:]' '[:lower:]')

else
echo "Using GitHub Container Registry (GHCR)"
REPO_NAME_LOWERCASE=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
REGISTRY_URL="ghcr.io/$REPO_NAME_LOWERCASE"
fi

echo "REGISTRY_URL=${REGISTRY_URL}" >> $GITHUB_ENV

# Step 7: Build Docker image
- name: Build Docker Image
run: |
IMAGE_NAME="taxonomy-api"
IMAGE_TAG=$(echo "${{ github.ref_name }}_$(echo $GITHUB_SHA | cut -c1-7)" | tr '[:upper:]' '[:lower:]')
docker build -f build/taxonomy-service/Dockerfile -t $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG} .

echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV

# Step 8: Push Docker Image
- name: Push Docker Image
run: |
docker push $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG}
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,42 @@ mvn play2:run
```shell
curl http://localhost:9000/health
```

### GitHub Actions Workflow Prerequisites

To ensure the GitHub Actions workflows in this repository function correctly, the following prerequisites must be met:

1. **Secrets Configuration**:
- Ensure the following secrets are configured in your GitHub repository:

#### GCP (Google Cloud Platform)
- `GCP_SERVICE_ACCOUNT_KEY`: Base64-encoded service account key for GCP.
- `REGISTRY_NAME`: GCP registry name (e.g., `asia-south1-docker.pkg.dev`).
- `REGISTRY_URL`: URL of the GCP container registry (e.g., `asia-south1-docker.pkg.dev/sunbird-morocco-sandbox-434709/sunbird-morocco-artifact-dev`).

#### DockerHub
- `REGISTRY_USERNAME`: DockerHub username.
- `REGISTRY_PASSWORD`: DockerHub password.
- `REGISTRY_NAME`: DockerHub registry name (e.g., `docker.io`).
- `REGISTRY_URL`: URL of the DockerHub registry. (e.g., `docker.io/<username>`)

#### Azure Container Registry (ACR)
- `REGISTRY_USERNAME`: ACR username (service principal or admin username).
- `REGISTRY_PASSWORD`: ACR password (service principal secret or admin password).
- `REGISTRY_NAME`: ACR registry name (e.g., `myregistry.azurecr.io`).
- `REGISTRY_URL`: URL of the ACR registry (e.g., `myregistry.azurecr.io`).

#### GitHub Container Registry (GHCR)
- `GITHUB_TOKEN`: GitHub token for authentication.
- `REGISTRY_NAME`: GitHub Container Registry name (e.g., `ghcr.io`).
- `REGISTRY_URL`: URL of the GHCR registry (e.g., `ghcr.io/<organization>/<repository>`).

Ensure these secrets are added to the repository settings under **Settings > Secrets and variables > Actions**.

2. **Environment Variables**:
- The following environment variables must be set in the repository or workflow:
- `CLOUD_STORE_GROUP_ID`: The group ID for cloud storage dependencies.
- `CLOUD_STORE_ARTIFACT_ID`: The artifact ID for cloud storage dependencies.
- `CLOUD_STORE_VERSION`: The version of the cloud storage dependencies.

By ensuring these prerequisites are met, the workflows in this repository will execute successfully.