-
Notifications
You must be signed in to change notification settings - Fork 17
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
Updating CI workflow (Deploying docker images to docker hub) #179
Changes from 10 commits
594ea33
2c02614
7810905
142f804
e403a69
673a81c
51fcbe5
163a705
78743b5
6a4c9e8
dfe90a0
5e81aa9
c171e06
49090bd
531b91c
4996a7a
17bb5e3
55bb133
deb83db
fa78a2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Build Save 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-save | ||
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 }} |
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') }} |
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 | ||
|
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 |
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 |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need to store these artifacts? Why not rather push to dockerhub with a commit hash as the tag? Then they are always available. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's mainly there for debugging purpose (hence the rentention only 2 days). Regarding pushing to docker hub, I think the plan was only to push images for main/releases, least dockerhub becomes too convoluted (and could also end up includes bugy images). @w-hayes thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just think we are going to pay for storing these. I think pushing them to a tag or doing not saving at all makes the most sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, will make it manual workflow (in case someone wants to use it to debug), and remove it from the event driven workflows. If this fine? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, that sounds fine. |
||
|
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 |
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 |
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 |
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 | ||
|
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 |
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 |
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' |
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 }} |
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 |
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.
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.
It looks like we will use the default app images for docker hub. I don't think these will be suitable as there are already images names that we should reuse - https://hub.docker.com/search?q=jempi
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.
Hmm...okay, noted. Will update as appropiate 👍🏽