-
Notifications
You must be signed in to change notification settings - Fork 177
Issue #SBCOSS-450 feat : Github Actions for knowledge platform #1103
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
Merged
pallakartheekreddy
merged 10 commits into
Sunbird-Knowlg:release-8.0.0
from
aimansharief:github-actions
May 22, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
862fa2c
Added content-service workflow
vinodbhorge 2a4598f
Added workflows for content, taxonomy and search
vinodbhorge 6f73644
Updated readme mentioned about the workflow pre requisites
vinodbhorge 6b1353c
Added a registry provider variable
vinodbhorge 61f5688
added echo statement
vinodbhorge 6397d49
Updated case statement to use same content for azure and dockerhub
vinodbhorge 13afee5
Updated Readme
vinodbhorge bee8d08
Merge pull request #14 from vinodbhorge/github-actions
aimansharief 30d105e
Updated github actions. Avoiding duplication of docker login step. Ad…
vinodbhorge 76e47ba
Merge pull request #15 from vinodbhorge/github-actions
aimansharief File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: "Container Registry Login" | ||
| description: "Reusable action for logging in to container registries using workflow inputs" | ||
| inputs: | ||
| registry_provider: | ||
| required: false | ||
| gcp_service_account_key: | ||
| required: false | ||
| registry_name: | ||
| required: false | ||
| registry_url: | ||
| required: false | ||
| registry_username: | ||
| required: false | ||
| registry_password: | ||
| required: false | ||
| github_token: | ||
| required: false | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - run: | | ||
| case "${{ inputs.registry_provider }}" in | ||
| "gcp") | ||
| echo "Using Google Container Registry" | ||
| echo "${{ inputs.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 ${{ inputs.registry_name }} | ||
| REGISTRY_URL=$(echo "${{ inputs.registry_url }}" | tr '[:upper:]' '[:lower:]') | ||
| ;; | ||
| "azure" | "dockerhub") | ||
| echo "Logging in to Container Registry" | ||
| echo "${{ inputs.registry_password }}" | docker login ${{ inputs.registry_name }} \ | ||
| --username ${{ inputs.registry_username }} --password-stdin | ||
| REGISTRY_URL=$(echo "${{ inputs.registry_url }}" | tr '[:upper:]' '[:lower:]') | ||
| ;; | ||
| *) | ||
| echo "Using GitHub Container Registry (GHCR)" | ||
| REPO_NAME_LOWERCASE=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]') | ||
| echo "${{ inputs.github_token }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
| REGISTRY_URL="ghcr.io/$REPO_NAME_LOWERCASE" | ||
| ;; | ||
| esac | ||
| echo "REGISTRY_URL=${REGISTRY_URL}" >> $GITHUB_ENV | ||
| shell: bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| 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: Set up Login to Docker registry | ||
| - name: Registry Login | ||
| uses: ./.github/actions/registry-login | ||
| with: | ||
| registry_provider: ${{ vars.REGISTRY_PROVIDER }} | ||
| gcp_service_account_key: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} | ||
| registry_name: ${{ secrets.REGISTRY_NAME }} | ||
| registry_url: ${{ secrets.REGISTRY_URL }} | ||
| registry_username: ${{ secrets.REGISTRY_USERNAME }} | ||
| registry_password: ${{ secrets.REGISTRY_PASSWORD }} | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| # Step 4: 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 5: Package the project | ||
| - name: Package Content Service | ||
| run: | | ||
| cd content-api | ||
| 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 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 | ||
|
|
||
| # Step 7: Push Docker Image | ||
| - name: Push Docker Image | ||
| run: | | ||
| docker push $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG} | ||
| echo "Pushed Docker image: $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| 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 3: Set up Login to Docker registry | ||
| - name: Registry Login | ||
| uses: ./.github/actions/registry-login | ||
| with: | ||
| registry_provider: ${{ vars.REGISTRY_PROVIDER }} | ||
| gcp_service_account_key: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} | ||
| registry_name: ${{ secrets.REGISTRY_NAME }} | ||
| registry_url: ${{ secrets.REGISTRY_URL }} | ||
| registry_username: ${{ secrets.REGISTRY_USERNAME }} | ||
| registry_password: ${{ secrets.REGISTRY_PASSWORD }} | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| # 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 | ||
| 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: 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 7: Push Docker Image | ||
| - name: Push Docker Image | ||
| run: | | ||
| docker push $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG} | ||
| echo "Pushed Docker image: $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| 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 3: Set up Login to Docker registry | ||
| - name: Registry Login | ||
| uses: ./.github/actions/registry-login | ||
| with: | ||
| registry_provider: ${{ vars.REGISTRY_PROVIDER }} | ||
| gcp_service_account_key: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} | ||
| registry_name: ${{ secrets.REGISTRY_NAME }} | ||
| registry_url: ${{ secrets.REGISTRY_URL }} | ||
| registry_username: ${{ secrets.REGISTRY_USERNAME }} | ||
| registry_password: ${{ secrets.REGISTRY_PASSWORD }} | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| # 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 | ||
| 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: 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 7: Push Docker Image | ||
| - name: Push Docker Image | ||
| run: | | ||
| docker push $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG} | ||
| echo "Pushed Docker image: $REGISTRY_URL/${IMAGE_NAME}:${IMAGE_TAG}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider clarifying what happens if 'REGISTRY_PROVIDER' is not explicitly set, so users have clear guidance on default behavior.