Skip to content

Commit

Permalink
Merge pull request #373 from buerokratt/dev
Browse files Browse the repository at this point in the history
Merging dev to test
  • Loading branch information
jaX10bt authored Jan 31, 2025
2 parents 2cc4b56 + a161b71 commit 2fbb13d
Show file tree
Hide file tree
Showing 71 changed files with 1,744 additions and 557 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RELEASE=PRE-ALPHA-test
VERSION=1
BUILD=1
FIX=5
FIX=36

19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Bug report
about: For reporting bugs
title: "[BUG]"
labels: bug
assignees: ''

---

**Bug description:**


**Expected behavior:**


**Screenshots:**


**Additional information:**
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Feature request
about: New feature or enhancement
title: ''
labels: ''
assignees: ''

---

**AS A** *role or user type*
**I WANT** *the feature or functionality desired*
**SO THAT** *desired outcome or goal*

### Acceptance Criteria

- [ ] ...
73 changes: 73 additions & 0 deletions .github/workflows/check-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Check Version

on:
push:
branches: ["test", "stage", "main"]
workflow_dispatch:

env:
BRANCH: ${{ github.head_ref || github.ref_name }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Docker Setup BuildX
uses: docker/setup-buildx-action@v2

- name: Bump Patch Version
run: npm run bump-patch
if: ${{ env.BRANCH == 'test' }}

- name: Sync Version
run: npm run sync-version
if: ${{ env.BRANCH != 'test' }}

- name: Generate Changelog
run: npm run changelog

- name: Push changes to repo
run: |
git config --global user.name ${{ secrets.ADMIN_NAME }}
git config --global user.email ${{ secrets.ADMIN_EMAIL }}
git add .
git commit -m "docs: update version"
git push
- name: Load environment variables
run: |
awk -v branch="${{ env.BRANCH }}" ' /^[0-9a-zA-Z]+$/ { current_branch = $0; } current_branch == branch && /^[A-Z_]+=/{ print $0; }' release.env >> $GITHUB_ENV
- name: Set repo
run: |
LOWER_CASE_GITHUB_REPOSITORY=$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')
echo "DOCKER_TAG_CUSTOM=ghcr.io/${LOWER_CASE_GITHUB_REPOSITORY}:v${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}" >> $GITHUB_ENV
echo "$GITHUB_ENV"
- name: Build Docker image
run: |
echo "Building Docker image for branch: ${{ env.BRANCH }} major: ${{ env.MAJOR }} minor: ${{ env.MINOR }} patch: ${{ env.PATCH }}"
docker image build --tag $DOCKER_TAG_CUSTOM --no-cache .
if: ${{ env.BRANCH == 'test' }}

- name: Log in to GitHub container registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Push Docker image to GitHub Packages
run: |
echo "Pushing Docker image to GitHub Packages"
docker push $DOCKER_TAG_CUSTOM
if: ${{ env.BRANCH == 'test' }}

- name: Create Release
uses: softprops/action-gh-release@v1
if: ${{ env.BRANCH == 'main' }}
with:
tag_name: v${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}
generate_release_notes: true
body_path: ${{ github.workspace }}/CHANGELOG.md
4 changes: 2 additions & 2 deletions .github/workflows/ci-build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and publish Chat-Widget
on:
push:
branches:
- dev
- v2.0.2
paths:
- '.env'

Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
echo "$GITHUB_ENV"
- name: Docker Build
run: |
docker image build -f Dockerfile --tag $DOCKER_TAG_CUSTOM .
docker image build -f Dockerfile --tag $DOCKER_TAG_CUSTOM --no-cache .
- name: Log in to GitHub container registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/create-release.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# !/bin/bash

message="$(head -1 $1)"

message_pattern="^(feat|fix|chore|docs|refactor|style|test)\([0-9]+\):\ .+$"

if ! [[ $message =~ $message_pattern ]];
then
echo "---"
echo "Violation of commit message format!"
echo "The commit message must follow the Conventional Commits standard:"
echo "[type(scope): description]"
echo "Example: feat(100): Implement automated pipeline for code commits"
echo "Accepted types: feat, fix, chore, docs, refactor, style, test"
echo "(1) feat: Added a new feature"
echo "(2) fix: Fixed a bug"
echo "(3) chore: Added changes that do not relate to a fix or feature and don't modify src or test files (for example updating dependencies)"
echo "(4) docs: Added updates to documentation such as a the README or other markdown files"
echo "(5) refactor: Refactored code that neither fixes a bug nor adds a feature"
echo "(6) style: Added Changes that do not affect the meaning of the code, likely related to code formatting such as white-space, missing semi-colons, and so on"
echo "(7) test: Included new or corrected previous tests"
echo "---"
exit 1
fi
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG node_version=node:lts
ARG nginx_version=nginx:1.25.4-alpine
ARG nginx_version=nginx:1.26.0-alpine


FROM $node_version AS image
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,38 @@ Snippet can be embedded to any site using the following html:
<script id="script-bundle" type="text/javascript" src="LOCATION_OF_WIDGET_BUNDLE" crossorigin=""></script>
```

## Iframe Support

If you want to use the widget inside an Iframe use the following snippet or reference iframe-index.html

```
<body>
<iframe
title="YOUR_IFRAME_TITLE"
id="YOUR_IFRAME_ID"
width="0"
height="0"
src="WIDGET_DOMAIN_URL"
scrolling="no"
style="YOUR_STYLE"
></iframe>
<script>
window.addEventListener(
"message",
(e) => {
const isOpened = e.data.isOpened;
if (isOpened != undefined) {
const iframe = window.document.getElementById("YOUR_IFRAME_ID");
iframe.width = isOpened ? "OPENED_WIDTH" : "CLOSED_WIDTH";
iframe.height = isOpened ? "OPENED_HEIGHT" : "CLOSED_HEIGHT";
}
},
false
);
</script>
</body>
```

## Configurable variables

- `RUUTER_API_URL`: Location of newer back end for fetching data
Expand Down
34 changes: 4 additions & 30 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
## v1.0.0-alpha.1 (2024-05-15)

> Description
### Upgrade Steps

- [ACTION REQUIRED]
-
## [v2.0.0](https://github.com/buerokratt/Chat-Widget/compare/main...dev)

### Breaking Changes

-
-

### New Features

-
-

### Bug Fixes

-
-

### Performance Improvements

-
-

### Other Changes

-
-
- Added Software Versioning [#561](https://github.com/buerokratt/Buerokratt-Chatbot/issues/561)
- Removed bugs and vulnerabilites [#5](https://github.com/buerokratt/Test-Driven-Development/issues/5)
- Serve static content on ngnix [#612](https://github.com/buerokratt/Buerokratt-Chatbot/issues/612)
96 changes: 96 additions & 0 deletions bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash

# This script is used to bump the version number based on the bump type provided to the current branch.

# Check if the bump type is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 {major|minor|patch}"
exit 1
fi

# Get the current branch name
current_branch=$(git branch --show-current)

# Initialize variables
found_branch=false
bump_type=$1

# Read the environment content from the file
env_file=$(<release.env)

# Get the version based on the current branch
while IFS= read -r line; do
if [ "$line" == "$current_branch" ]; then
found_branch=true
elif [ "$found_branch" == true ]; then
if [[ "$line" == MAJOR=* || "$line" == MINOR=* || "$line" == PATCH=* ]]; then
var_name="${line%%=*}"
var_value="${line#*=}"

if [[ "$var_name" == "MAJOR" || "$var_name" == "MINOR" || "$var_name" == "PATCH" ]]; then
declare -i "$var_name=$var_value"
fi
else
break
fi
fi
done <<< "$env_file"

# Increment the version number based on the bump type
if [ "$found_branch" == true ]; then
case "$bump_type" in
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
*)
echo "Invalid bump type: $bump_type"
exit 1
;;
esac

updated_content=$(awk -v branch="$current_branch" -v major="$MAJOR" -v minor="$MINOR" -v patch="$PATCH" '
BEGIN { found = 0 }
$0 == branch {
print $0;
found=1;
next
}
# If the branch was found, replace MAJOR, MINOR, and PATCH values
found && $0 ~ /^MAJOR=/ {
print "MAJOR=" major
next
}
found && $0 ~ /^MINOR=/ {
print "MINOR=" minor
next
}
found && $0 ~ /^PATCH=/ {
print "PATCH=" patch
next
}
# Check for the start of a new branch. If a new branch is found, stop processing the values of the previous branch.
/^[a-zA-Z]+$/ {
if (found) {
found = 0 # Reset found when a new branch is encountered
}
}
# If we have not found the branch yet, just print the line
{ print $0 }
' release.env)

echo -e "$updated_content" > "release.env"
fi
Loading

0 comments on commit 2fbb13d

Please sign in to comment.