-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cicd pipeline to test and deploy the core to the remote server - … (
#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
Showing
4 changed files
with
61 additions
and
2 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,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 | ||
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