added models and repositories #20
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
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 | |