Skip to content

Commit

Permalink
👷 upgrade version & deploy (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
heavynimbus authored Jun 1, 2024
1 parent 1ce608d commit cef5174
Show file tree
Hide file tree
Showing 24 changed files with 429 additions and 186 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ updates:
- package-ecosystem: maven
directory: /server
schedule:
interval: weekly
interval: daily
target-branch: main
commit-message:
prefix: '⬆️ Upgrade'
1 change: 1 addition & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- main
- develop

jobs:
build:
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/upgrade-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Upgrade Version and Deploy

on:
push:
branches:
- 'main'

jobs:
upgrade-version:
runs-on: ubuntu-latest

permissions:
packages: write
contents: write

steps:
- name: Docker Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Check out the repo
uses: actions/checkout@v4

- name: Setup Java 21
uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: '21.0.3'
cache: 'maven'
cache-dependency-path: 'server/pom.xml'

- name: Retrieve next version
id: next-version
run: |
echo "value=$(./get-next-version.sh)" >> $GITHUB_OUTPUT
- name: Upgrade server version
run: |
./set-next-version.sh --pom server/pom.xml
- name: Create Tag ${{ steps.next-version.outputs.value }}
uses: rickstaa/action-create-tag@v1
id: "tag_create"
with:
tag: "v${{ steps.next-version.outputs.value }}"
message: "️⬆️ Upgrade server version to ${{ steps.next-version.outputs.value }}"


- name: Build Docker image ${{ steps.next-version.outputs.value }}
env:
NEXT_VERSION: ${{ steps.next-version.outputs.value }}
run: |
docker build -t heavy-mock-http-server:$NEXT_VERSION server
- name: Push Docker image ${{ steps.next-version.outputs.value }}
env:
NEXT_VERSION: ${{ steps.next-version.outputs.value }}
run: |
docker tag "heavy-mock-http-server:$NEXT_VERSION" "heavynimbus/heavy-mock-http-server:$NEXT_VERSION"
docker push "heavynimbus/heavy-mock-http-server:$NEXT_VERSION"
- name: Set snapshot version
run: |
./set-next-version.sh --pom server/pom.xml --snapshot
- name: Retrieve snapshot version
id: snapshot-version
run: |
echo "value=$(echo $(./get-next-version.sh)-SNAPSHOT)" >> $GITHUB_OUTPUT
- name: Commit and push snapshot version ${{ steps.snapshot-version.outputs.value }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "⬆️ Upgrade server version to ${{ steps.snapshot-version.outputs.value }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
70 changes: 1 addition & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ services:

## 🛠️ Configuration


*Definition*:
```yaml
endpoints:
Expand Down Expand Up @@ -89,71 +88,4 @@ endpoints:
body:
string: <string>
file: <string>
```


*Simple Example*:
```yaml
# Your HEAVY_MOCK_CONFIG file
# Declaration of endpoints
endpoints:
# First endpoint
- name: Get Hello Heavy
# If the request matches the following criteria, the response will be returned
request:
methods:
- GET
paths:
- /hello/heavy
# The response to be returned
response:
status: OK
headers:
"Content-Type":
- application/json
body: |
{
"message": "Hello, Heavy!"
}
- name: Get Hello for any other path
# If the request matches the following criteria, the response will be returned
request:
methods:
- GET
paths:
- /hello/.* # This is a regular expression
# The response to be returned
response:
status: OK
headers:
"Content-Type":
- application/json
body: |
{
"message": "Hello, World!"
}
- name: 404 Not Found
# If the request matches the following criteria, the response will be returned
request:
methods:
- GET
paths:
- /not-found
# The response to be returned
response:
status: NOT_FOUND
headers:
"Content-Type":
- application/json
body: |
{
"message": "Not Found"
}
```
```
84 changes: 84 additions & 0 deletions examples/delayed-endpoints.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Declaration of endpoints
endpoints:
- name: No Delay Hello
# If the request matches the following criteria, the response will be returned
request:
methods:
- GET
paths:
- /hello/no-delay # This is a regular expression

# The response to be returned
response:
status: OK
headers:
"Content-Type":
- application/json
body:
content: |
{
"message": "Hello, Heavy!"
}
- name: 200ms Delayed Hello
# If the request matches the following criteria, the response will be returned
request:
methods:
- GET
paths:
- /hello/200 # This is a regular expression

# The response to be returned
response:
delay: 200
status: OK
headers:
"Content-Type":
- application/json
body:
content: |
{
"message": "Hello, Heavy!"
}
- name: 500ms Delayed Hello
# If the request matches the following criteria, the response will be returned
request:
methods:
- GET
paths:
- /hello/500 # This is a regular expression

# The response to be returned
response:
delay: 500
status: OK
headers:
"Content-Type":
- application/json
body:
content: |
{
"message": "Hello, Heavy!"
}
- name: 1000ms Delayed Hello
# If the request matches the following criteria, the response will be returned
request:
methods:
- GET
paths:
- /hello/1000 # This is a regular expression

# The response to be returned
response:
delay: 1000
status: OK
headers:
"Content-Type":
- application/json
body:
content: |
{
"message": "Hello, Heavy!"
}
4 changes: 0 additions & 4 deletions examples/error-404.json

This file was deleted.

62 changes: 62 additions & 0 deletions examples/multiple-endpoints.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Declaration of endpoints
endpoints:
# First endpoint
- name: Get Hello
# If the request matches the following criteria, the response will be returned
request:
methods:
- GET
paths:
- /hello/heavy

# The response to be returned
response:
status: OK
headers:
"Content-Type":
- application/json
body:
content: |
{
"message": "Hello, Heavy!"
}
- name: Get Hello
# If the request matches the following criteria, the response will be returned
request:
methods:
- GET
paths:
- /hello/.* # This is a regular expression

# The response to be returned
response:
status: OK
headers:
"Content-Type":
- application/json
body:
content: |
{
"message": "Hello, World!"
}
- name: 404 Not Found
# If the request matches the following criteria, the response will be returned
request:
methods:
- GET
paths:
- /not-found

# The response to be returned
response:
status: NOT_FOUND
headers:
"Content-Type":
- application/json
body:
content: |
{
"message": "Not Found"
}
File renamed without changes.
3 changes: 3 additions & 0 deletions get-next-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

grep -rE 'version.next=[0-9]+\.[0-9]+\.[0-9]+' version.properties | cut -d '=' -f2
31 changes: 24 additions & 7 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.0</version>
<relativePath/> <!-- lookup parent from repository -->
<relativePath/>
</parent>

<groupId>heavynimbus</groupId>
<artifactId>server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>server</name>
<description>server</description>
<artifactId>heavy-mock-http-server</artifactId>
<version>0.0.0-SNAPSHOT</version>
<description>
Mock HTTP server for development or testing purposes, with the ability to mock responses based on request
parameters.
</description>

<properties>
<java.version>21</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
Expand Down Expand Up @@ -50,6 +54,20 @@
</dependencies>

<build>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>
src/test/resources
</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand All @@ -73,5 +91,4 @@
</plugin>
</plugins>
</build>

</project>
Loading

0 comments on commit cef5174

Please sign in to comment.