Skip to content

Commit

Permalink
add cicd pipeline to test and deploy the core to the remote server - … (
Browse files Browse the repository at this point in the history
#53)

* add cicd pipeline to test and deploy the core to the remote server - minimal setup, server is expected to be configured correctly

* remove comment from .yml

* Update readme to include workflow status badge

* add api server endpoints to openapi docs

* use relative path to swagger.json
  • Loading branch information
JustDaile authored Jul 16, 2024
1 parent d2c1b4b commit 68e8b16
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 2 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Go

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
TARGET_DIR: /home/${{secrets.SSH_USERNAME}}/apps/event-mgmt-core
DB_DSN: "postgres://${{secrets.DATABASE_USER}}:${{secrets.DATABASE_PASSWORD}}@${{secrets.DATABASE_HOST}}:${{secrets.DATABASE_PORT}}/${{secrets.DATABASE_NAME}}?sslmode=${{secrets.DATABASE_SSL_MODE}}"

jobs:

build:
runs-on: ubuntu-latest
steps:
# Checkout makes source available for remote deploy.
- uses: actions/checkout@v4

# Setup Golang for build and testing.
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.3'

# Run tests
- name: Test
run: go test -v ./...

# Deploys all the source (currently).
# Might be better to deploy only the compiled binary and do additional setup.
- name: Remote deploy
uses: cross-the-world/[email protected]
with:
host: ${{secrets.SSH_HOST}}
key: ${{secrets.SSH_KEY}}
user: ${{secrets.SSH_USERNAME}}
first_ssh: |
rm -rf $TARGET_DIR
mkdir -p $TARGET_DIR
scp: |-
"." => $TARGET_DIR
last_ssh: |-
cd $TARGET_DIR
/usr/local/go/bin/go build -o bin/emc main.go
/usr/local/bin/migrate -path=./migrations -database=$DB_DSN up
systemctl --user restart event-mgmt-core
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Event Management System
# Event Management System
[![Go](https://github.com/BEOpenSourceCollabs/EventManagementCore/actions/workflows/go.yml/badge.svg)](https://github.com/BEOpenSourceCollabs/EventManagementCore/actions/workflows/go.yml)

User management - login / sign up / roles assigned to users ( organisers, admins and normal users)

Expand Down
9 changes: 9 additions & 0 deletions static/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
"servers": [
{
"url": "http://localhost:8081/api"
},
{
"url": "https://api.event-local.online/api"
},
{
"url": "https://dev-api.event-local.online/api"
},
{
"url": "https://qa-api.event-local.online/api"
}
],
"tags": [
Expand Down
2 changes: 1 addition & 1 deletion static/swagger/swagger-initializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ window.onload = function() {

// the following lines will be replaced by docker/configurator, when it runs in a docker-container
window.ui = SwaggerUIBundle({
url: "http://localhost:8081/swagger.json",
url: "/swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
Expand Down

0 comments on commit 68e8b16

Please sign in to comment.