forked from EVOLVED-5G/NEF_emulator
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #3 from MagalhaesD77/main
NEF Helm Chart
- Loading branch information
Showing
32 changed files
with
933 additions
and
26 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,64 @@ | ||
# | ||
name: Publish Docker images | ||
|
||
# Configures this workflow to run every time a change is pushed to the branch. | ||
on: | ||
push: | ||
branches: ['main'] | ||
|
||
# Custom environment variables for the workflow. | ||
env: | ||
REGISTRY: atnog-harbor.av.it.pt | ||
PROJECT: route25 | ||
latest-branch: main | ||
|
||
# Jobs in this workflow. | ||
jobs: | ||
build-and-push-docker-images: | ||
runs-on: ubuntu-24.04 | ||
|
||
# Matrix to run job multiple times with different configurations. | ||
strategy: | ||
fail-fast: true # Stops the job as soon as one of the matrix entries fails. | ||
matrix: | ||
include: | ||
- dir: backend | ||
file: Dockerfile.backend | ||
repository: backend | ||
- dir: backend | ||
file: Dockerfile.report | ||
repository: report | ||
|
||
# Steps in this job. | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Log in to the Registry | ||
uses: docker/[email protected] | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ secrets.REGISTRY_USERNAME }} | ||
password: ${{ secrets.REGISTRY_PASSWORD }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/[email protected] | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.PROJECT }}/${{ matrix.repository }} | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=ref,event=branch | ||
type=sha | ||
- name: Build and push Docker image | ||
uses: docker/[email protected] | ||
with: | ||
context: ${{ matrix.dir }} | ||
file: ${{ matrix.dir }}/${{ matrix.file }} | ||
tags: | # Tags for the Docker image. latest for the main branch, branch name for the lastest of each branch, and commit hash for each commit. | ||
${{ github.ref_name == env.latest-branch && format('{0}/{1}/{2}:latest', env.REGISTRY, env.PROJECT, matrix.repository) || '' }} | ||
${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
push: true | ||
|
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,85 @@ | ||
# | ||
name: Publish Helm Chart | ||
|
||
# Configures this workflow to run every time a change is pushed to the branch. | ||
on: | ||
push: | ||
branches: ['main'] | ||
|
||
# Custom environment variables for the workflow. | ||
env: | ||
REGISTRY: atnog-harbor.av.it.pt | ||
PROJECT: route25 | ||
|
||
# Jobs in this workflow. | ||
jobs: | ||
package-and-push-helm-chart: | ||
runs-on: ubuntu-24.04 | ||
|
||
# Matrix to run job multiple times with different configurations. | ||
strategy: | ||
fail-fast: true # Stops the job as soon as one of the matrix entries fails. | ||
matrix: | ||
include: | ||
- dir: helm-chart | ||
|
||
# Steps in this job. | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Log in to the Registry | ||
uses: docker/[email protected] | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ secrets.REGISTRY_USERNAME }} | ||
password: ${{ secrets.REGISTRY_PASSWORD }} | ||
|
||
- name: Helm Chart Package and Push | ||
shell: bash | ||
run: | | ||
# Package the Helm Chart and capture the path | ||
CHART_PATH=$(helm package ${{ matrix.dir }} -u | awk '{print $NF}') | ||
# Run the helm push command and capture both stdout and stderr | ||
OUTPUT=$(helm push $CHART_PATH oci://${{ env.REGISTRY }}/${{ env.PROJECT }} 2>&1) | ||
echo "Raw Output: $OUTPUT" | ||
# Check if the helm push command was successful | ||
if [ $? -ne 0 ]; then | ||
echo "Helm push failed." | ||
exit 1 | ||
fi | ||
# Extract the Digest from the output | ||
DIGEST=$(echo "$OUTPUT" | grep "Digest:" | awk '{print $2}') | ||
# Extract the Chart Name from the output | ||
CHART_NAME=$(echo "$OUTPUT" | grep "Pushed:" | awk '{print $2}' | awk -F '/' '{print $NF}'| cut -d':' -f1) | ||
# Print the results | ||
echo "Digest: $DIGEST" | ||
echo "Chart Name: $CHART_NAME" | ||
# Add tags to the Helm Chart | ||
for tag in ${{ github.ref_name == 'main' && 'latest' || '' }} ${{ github.ref_name }} ${{ github.sha }} ; do | ||
# if tag is '' or empty, skip the tagging | ||
if [ -z "$tag" ]; then | ||
continue | ||
fi | ||
echo "Tagging $CHART_NAME with $tag" | ||
curl -u '${{ secrets.REGISTRY_USERNAME }}:${{ secrets.REGISTRY_PASSWORD }}' -X 'POST' \ | ||
"https://${{ env.REGISTRY }}/api/v2.0/projects/${{ env.PROJECT }}/repositories/$CHART_NAME/artifacts/$DIGEST/tags" \ | ||
-H 'accept: application/json' \ | ||
-H 'Content-Type: application/json' \ | ||
-d '{ | ||
"id": 0, | ||
"repository_id": 0, | ||
"artifact_id": 0, | ||
"name": "'$tag'", | ||
"immutable": true | ||
}' | ||
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
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
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
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
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 |
---|---|---|
@@ -1,13 +1,50 @@ | ||
#!/bin/bash | ||
|
||
PORT=8888 | ||
URL=http://localhost | ||
PORT=8888 | ||
REPORT_PORT=3000 | ||
FIRST_SUPERUSER="[email protected]" | ||
FIRST_SUPERUSER_PASSWORD="pass" | ||
|
||
set -a # automatically export all variables | ||
source .env | ||
set +a | ||
|
||
# help | ||
for arg in "$@"; do | ||
if [ "$arg" == "--help" ]; then | ||
echo "Usage: cmd [-h URL] [-p PORT] [-r REPORT_PORT] [-n FIRST_SUPERUSER] [-u FIRST_SUPERUSER_PASSWORD] [--help]" | ||
exit 0 | ||
fi | ||
done | ||
|
||
# get opts | ||
while getopts ":h:p:r:n:u:s:" opt; do | ||
case ${opt} in | ||
h ) | ||
URL=$OPTARG | ||
;; | ||
p ) | ||
PORT=$OPTARG | ||
;; | ||
r ) | ||
REPORT_PORT=$OPTARG | ||
;; | ||
u ) | ||
FIRST_SUPERUSER=$OPTARG | ||
;; | ||
# Secret | ||
s ) | ||
FIRST_SUPERUSER_PASSWORD=$OPTARG | ||
;; | ||
\? ) | ||
echo "Invalid option: -$OPTARG" >&2 | ||
echo "Usage: cmd [-h URL] [-p PORT] [-r REPORT_PORT] [-n FIRST_SUPERUSER] [-u FIRST_SUPERUSER_PASSWORD] [--help]" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
printf '\n==================================================\n' | ||
printf 'Create Report' | ||
printf '\n==================================================\n' | ||
|
@@ -452,12 +489,12 @@ curl -X 'POST' \ | |
"path": 2 | ||
}' | ||
|
||
printf '\n==================================================\n' | ||
printf 'Delete Report' | ||
printf '\n==================================================\n' | ||
# printf '\n==================================================\n' | ||
# printf 'Delete Report' | ||
# printf '\n==================================================\n' | ||
|
||
|
||
curl -X 'DELETE' \ | ||
"${URL}:${REPORT_PORT}/report" \ | ||
# curl -X 'DELETE' \ | ||
# "${URL}:${REPORT_PORT}/report" \ | ||
|
||
printf '\n==================================================\n\n' | ||
# printf '\n==================================================\n\n' |
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
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,8 @@ | ||
name: nef-emulator | ||
description: Helm Chart for NEF emulator | ||
version: 0.0.1 | ||
apiVersion: v2 | ||
keywords: | ||
- nef-emulator | ||
sources: | ||
home: |
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 @@ | ||
# NEF emulator Helm Chart |
Oops, something went wrong.