-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #179 from jembi/dev_ci_update
Updating CI workflow (Deploying docker images to docker hub)
- Loading branch information
Showing
35 changed files
with
652 additions
and
84 deletions.
There are no files selected for viewing
This file contains 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,27 @@ | ||
name: Action > Build | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: ./.github/workflows/actions/cached-dependencies | ||
- name: Build javascript app (ui) | ||
run: | | ||
source "$HOME/.nvm/nvm.sh" | ||
cd $JEMPI_APP_PATH/JeMPI_UI | ||
yarn install --frozen-lockfile | ||
yarn build | ||
shell: bash | ||
- name: Build Scala Apps | ||
run: | | ||
set -eo pipefail | ||
source "$HOME/.sdkman/bin/sdkman-init.sh" | ||
cd $JEMPI_APP_PATH/JeMPI_EM_Scala | ||
sbt clean assembly | ||
shell: bash | ||
- name: Build Java App | ||
run: | | ||
set -eo pipefail | ||
source "$HOME/.sdkman/bin/sdkman-init.sh" | ||
cd $JEMPI_APP_PATH | ||
mvn clean package | ||
shell: bash |
This file contains 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,25 @@ | ||
name: Build and Deploy Images | ||
inputs: | ||
docker-push-tag: | ||
required: false | ||
image-build-tag: | ||
required: true | ||
docker-host: | ||
required: true | ||
docker-username: | ||
required: true | ||
docker-password: | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: ./.github/workflows/actions/docker-images-build | ||
with: | ||
image-build-tag: ${{ inputs.image-build-tag }} | ||
- uses: ./.github/workflows/actions/docker-images-deploy | ||
with: | ||
image-build-tag: ${{ inputs.image-build-tag }} | ||
docker-push-tag: ${{ inputs.docker-push-tag }} | ||
docker-username: ${{ inputs.docker-username }} | ||
docker-password: ${{ inputs.docker-password }} | ||
docker-host: ${{ inputs.docker-host }} |
This file contains 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,15 @@ | ||
name: Action > CacheDependencies | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Cache SDKMan Install | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.sdkman | ||
~/.nvm | ||
~/.npm | ||
~/.cache/yarn | ||
$GITHUB_WORKSPACE/JeMPI_Apps/JeMPI_UI/node_modules | ||
# Using the prepare file as it contains all the version of the dependencies | ||
key: build-dependencies-${{ hashFiles('**/.github/workflows/actions/prepare/action.yml', '**/yarn.lock') }} |
This file contains 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,22 @@ | ||
name: Action > Docker Images Build | ||
inputs: | ||
image-build-tag: | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: ./.github/workflows/actions/cached-dependencies | ||
- uses: ./.github/workflows/actions/load-conf-env | ||
- name: Build Docker Images | ||
run: | | ||
set -eo pipefail | ||
source "$HOME/.nvm/nvm.sh" | ||
source "$HOME/.sdkman/bin/sdkman-init.sh" | ||
source $GITHUB_WORKSPACE/devops/linux/docker/conf.env | ||
source $GITHUB_WORKSPACE/devops/linux/docker/conf/images/conf-app-images.sh | ||
pushd $GITHUB_WORKSPACE/JeMPI_Apps | ||
source ./build-all-ci.sh "${{ inputs.image-build-tag }}" | ||
popd | ||
docker image ls | ||
shell: bash | ||
|
This file contains 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,24 @@ | ||
name: Deploy Docker Images | ||
inputs: | ||
image-build-tag: | ||
required: true | ||
docker-push-tag: | ||
required: false | ||
docker-host: | ||
required: true | ||
docker-username: | ||
required: true | ||
docker-password: | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- run: | | ||
set -eo pipefail | ||
source $GITHUB_WORKFLOW_FOLDER/actions/docker-images-deploy/deployDockerImages.sh \ | ||
"${{ inputs.image-build-tag }}" \ | ||
"${{ inputs.docker-push-tag }}" \ | ||
"${{ inputs.docker-host }}" \ | ||
"${{ inputs.docker-username }}" \ | ||
"${{ inputs.docker-password }}" | ||
shell: bash |
35 changes: 35 additions & 0 deletions
35
.github/workflows/actions/docker-images-deploy/deployDockerImages.sh
This file contains 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,35 @@ | ||
#!/bin/bash | ||
|
||
original_tag=$1 | ||
push_tag=$2 | ||
registry_url=$3 | ||
username=$4 | ||
password=$5 | ||
|
||
if [ -z "$registry_url" ] || [ -z "$username" ] || [ -z "$password" ]; then | ||
echo "Docker host details not set. Skipping deploying" | ||
exit 0 | ||
fi | ||
|
||
|
||
if [ -z "$push_tag" ]; then | ||
push_tag=$original_tag | ||
fi | ||
|
||
if ! docker login "$registry_url" -u "$username" -p "$password"; then | ||
echo "Failed to authenticate with Docker registry. Cannot push." | ||
exit 1 | ||
fi | ||
|
||
|
||
IMAGE_LIST=$(docker image ls --filter "reference=*:$original_tag" --format "{{.Repository}}:{{.Tag}}") | ||
|
||
for IMAGE in $IMAGE_LIST; do | ||
IFS=':' read -a image_details <<< "$IMAGE" | ||
push_tag_url="$registry_url/$username/${image_details[0]}:$push_tag" | ||
|
||
echo "Pushing image: $IMAGE to '$push_tag_url'" | ||
|
||
docker tag "$IMAGE" $push_tag_url | ||
docker push $push_tag_url | ||
done |
This file contains 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,21 @@ | ||
name: Action > Docker Images Build | ||
inputs: | ||
image-build-tag: | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: ./.github/workflows/actions/cached-dependencies | ||
- uses: ./.github/workflows/actions/load-conf-env | ||
- name: Build Docker Save | ||
run: | | ||
set -eo pipefail | ||
source $GITHUB_WORKFLOW_FOLDER/actions/docker-images-save/saveImages.sh "${{ inputs.image-build-tag }}" "./.github/workflows/actions/docker-images-save/docker-images" | ||
shell: bash | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: docker-images-${{ inputs.image-build-tag }} | ||
path: | | ||
./.github/workflows/actions/docker-images-save/docker-images/ | ||
retention-days: 2 | ||
|
15 changes: 15 additions & 0 deletions
15
.github/workflows/actions/docker-images-save/saveImages.sh
This file contains 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,15 @@ | ||
#!/bin/bash | ||
|
||
images_path="$2" | ||
|
||
if [ ! -d "$images_path" ]; then | ||
mkdir -p "$images_path" | ||
fi | ||
|
||
IMAGE_LIST=$(docker image ls --filter "reference=*:$1" --format "{{.Repository}}:{{.Tag}}") | ||
|
||
for IMAGE in $IMAGE_LIST; do | ||
IFS=':' read -a image_details <<< "$IMAGE" | ||
echo "Saving image: $IMAGE to '$images_path/${image_details[0]}.${image_details[1]}.tar'" | ||
docker save -o "$images_path/${image_details[0]}.${image_details[1]}.tar" "$IMAGE" | ||
done |
This file contains 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,24 @@ | ||
name: Install Node | ||
inputs: | ||
node-version: | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Install Nvm | ||
shell: bash | ||
run: | | ||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash | ||
source "$HOME/.nvm/nvm.sh" | ||
nvm --version | ||
- name: Install node ${{ inputs.node-version }} | ||
run: | | ||
source "$HOME/.nvm/nvm.sh" | ||
nvm install ${{ inputs.node-version }} | ||
shell: bash | ||
- name: Install UI packages | ||
run: | | ||
source "$HOME/.nvm/nvm.sh" | ||
cd $JEMPI_APP_PATH/JeMPI_UI | ||
yarn install --frozen-lockfile | ||
shell: bash |
This file contains 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,10 @@ | ||
name: Install SDKMan | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Install SDKMan | ||
shell: bash | ||
run: | | ||
curl -s "https://get.sdkman.io" | bash | ||
source "$HOME/.sdkman/bin/sdkman-init.sh" | ||
sdk version |
This file contains 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,20 @@ | ||
name: Action > Lint | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: ./.github/workflows/actions/cached-dependencies | ||
- name: Running javascript linter | ||
run: | | ||
source "$HOME/.nvm/nvm.sh" | ||
cd $JEMPI_APP_PATH/JeMPI_UI | ||
yarn install --frozen-lockfile | ||
yarn lint && yarn format | ||
shell: bash | ||
- name: Running java linter | ||
run: | | ||
set -eo pipefail | ||
source "$HOME/.sdkman/bin/sdkman-init.sh" | ||
source $GITHUB_WORKFLOW_FOLDER/actions/lint/mvn_linter.sh $JEMPI_APP_PATH | ||
shell: bash | ||
|
This file contains 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,11 @@ | ||
#!/bin/bash | ||
|
||
cd "$1" | ||
|
||
for dir in */; do | ||
dir="${dir%/}" | ||
if [ -f "$dir/pom.xml" ]; then | ||
echo "Running Checkstyle for $dir ..." | ||
mvn -f "$dir/pom.xml" checkstyle:check -Dcheckstyle.suppressions.location="$dir/checkstyle/suppression.xml" | ||
fi | ||
done |
This file contains 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,12 @@ | ||
name: Action > Load Conf Env | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Load Conf Env | ||
run: | | ||
pushd $GITHUB_WORKSPACE/devops/linux/docker/conf/env | ||
./create-env-linux-high-1.sh | ||
popd | ||
source $GITHUB_WORKSPACE/devops/linux/docker/conf.env | ||
shell: bash |
This file contains 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,33 @@ | ||
name: Prepare | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: ./.github/workflows/actions/cached-dependencies | ||
id: cache-dependencies | ||
- if: ${{ steps.cache-dependencies.outputs.cache-hit != 'true' }} | ||
name: Set up Node | ||
uses: ./.github/workflows/actions/install-node | ||
with: | ||
node-version: 20 | ||
- if: ${{ steps.cache-dependencies.outputs.cache-hit != 'true' }} | ||
name: Set up SDKMan | ||
uses: ./.github/workflows/actions/install-sdkman | ||
- if: ${{ steps.cache-dependencies.outputs.cache-hit != 'true' }} | ||
name: Set up Java | ||
uses: ./.github/workflows/actions/sdkman-installer | ||
with: | ||
candidate: java | ||
version: '21.0.1-tem' | ||
- if: ${{ steps.cache-dependencies.outputs.cache-hit != 'true' }} | ||
name: Set up Maven | ||
uses: ./.github/workflows/actions/sdkman-installer | ||
with: | ||
candidate: maven | ||
version: '3.9.5' | ||
- if: ${{ steps.cache-dependencies.outputs.cache-hit != 'true' }} | ||
name: Set Scala Build Tools | ||
uses: ./.github/workflows/actions/sdkman-installer | ||
with: | ||
candidate: sbt | ||
version: '1.9.8' |
This file contains 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,15 @@ | ||
name: SDKMan Installer | ||
inputs: | ||
candidate: | ||
required: true | ||
version: | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Installing ${{ inputs.candidate }} (version ${{ inputs.version }}) | ||
shell: bash | ||
run: | | ||
echo "$HOME/.sdkman/bin/sdkman-init.sh" | ||
source "$HOME/.sdkman/bin/sdkman-init.sh" | ||
sdk install ${{ inputs.candidate }} ${{ inputs.version }} |
This file contains 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,7 @@ | ||
name: Action > Smoke Test | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 |
This file contains 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,20 @@ | ||
name: Action > Test | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: ./.github/workflows/actions/cached-dependencies | ||
- name: Testing Java Apps | ||
run: | | ||
set -eo pipefail | ||
source "$HOME/.sdkman/bin/sdkman-init.sh" | ||
cd $JEMPI_APP_PATH | ||
mvn clean test | ||
shell: bash | ||
- name: Testing javascript app (ui) | ||
run: | | ||
source "$HOME/.nvm/nvm.sh" | ||
cd $JEMPI_APP_PATH/JeMPI_UI | ||
yarn install --frozen-lockfile | ||
yarn run test -- --watchAll=false | ||
shell: bash |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.