Skip to content

Commit

Permalink
feat: Init the pproject
Browse files Browse the repository at this point in the history
  • Loading branch information
sirateek committed Apr 17, 2023
1 parent 5dd7807 commit ebc64d1
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build Docker Image and Release Github

on:
push:
branches: ["master"]

jobs:
release-on-github:
runs-on: ubuntu-latest
outputs:
newTag: ${{ steps.semver_rel.outputs.new_tag }}
previousTag: ${{ steps.semver_rel.outputs.previous_tag }}
changeLogs: ${{ steps.github_release.outputs.changelog }}
steps:
# Fetch all repository details (Including tag for semver).
- uses: actions/checkout@v3
with:
fetch-depth: 0

# Determan new version by using Semver logic.
- name: Semver Release
id: semver_rel
uses: hennejg/github-tag-action@v4.3.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

# Generate Change Log
- name: Release Changelog Builder
id: github_release
uses: mikepenz/release-changelog-builder-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fromTag: ${{ steps.semver_rel.outputs.previous_tag }}
toTag: ${{ steps.semver_rel.outputs.new_tag }}

# Create a release on Github Repo.
- name: Create Release
uses: mikepenz/action-gh-release@v0.2.0-a03 #softprops/action-gh-release
with:
body: ${{ steps.github_release.outputs.changelog }}
tag_name: ${{ steps.semver_rel.outputs.new_tag }}

build-docker-image:
runs-on: ubuntu-latest
needs: release-on-github
steps:
# Fetch all repository details (Including tag for semver).
- uses: actions/checkout@v3

- uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.SSH_COMMON_GO_PRIVATE_KEY }}

# Login to DockerHub by using the credentials.
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

# Setup BuildX
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Build Docker Image and push to docker hub.
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ format('ghcr.io/garnbarn/gb-assignment-service:{0}', needs.release-on-github.outputs.newTag) }}
github-token: ${{ secrets.GITHUB_TOKEN }}
platforms: |
linux/amd64
linux/arm64
ssh: |
default
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
run:
go run .

run-compose:
COMPOSE_PROJECT_NAME=garnbarn-assignment docker-compose up -d
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: 3.0.0
services:
db-assignment:
image: mysql:8.0.32
ports:
- 3306:3306
environment:
- MYSQL_ROOT_PASSWORD=P@ssw0rd
- MYSQL_DATABASE=garnbarn-assignment

rabbit:
image: rabbitmq:management-alpine
ports:
- 15672:15672
- 5672:5672
volumes:
- type: bind
source: ./rabbitmq/rabbitmq.config
target: /etc/rabbitmq/rabbitmq.config
- type: bind
source: ./rabbitmq/rabbitmq-definitions.json
target: /etc/rabbitmq/rabbitmq-definitions.json
environment:
- RABBITMQ_DEFAULT_USER=guest
- RABBITMQ_DEFAULT_PASS=guest

phpmyadmin:
image: phpmyadmin:5.2.1
restart: always
ports:
- 8080:80
links:
- db-assignment
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/GarnBarn/gb-assignment-consumer

go 1.20
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("HelloWorld")
}
49 changes: 49 additions & 0 deletions rabbitmq/rabbitmq-definitions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"exchanges": [
{
"name": "assignment",
"vhost": "/",
"type": "fanout",
"durable": true,
"auto_delete": false,
"internal": false,
"arguments": {}
}
],
"queues": [
{
"name": "create-assignment-queue",
"vhost": "/",
"durable": true,
"auto_delete": false,
"arguments": {}
}
],
"bindings": [
{
"source": "assignment",
"vhost": "/",
"destination": "create-assignment-queue",
"destination_type": "queue",
"routing_key": "create",
"arguments": {}
}
],
"vhosts": [{ "name": "/" }],
"users": [
{
"name": "guest",
"password": "guest",
"tags": "administrator"
}
],
"permissions": [
{
"user": "guest",
"vhost": "/",
"configure": ".*",
"write": ".*",
"read": ".*"
}
]
}
8 changes: 8 additions & 0 deletions rabbitmq/rabbitmq.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
rabbitmq_management,
[
{ load_definitions, "/etc/rabbitmq/rabbitmq-definitions.json" }
]
}
].

0 comments on commit ebc64d1

Please sign in to comment.