Migate build and deploy to Mage

This commit is contained in:
Ryan Harg 2024-07-11 10:29:54 +02:00
parent b2c60a0a6a
commit 2210b89f85
4 changed files with 28 additions and 8 deletions

View file

@ -1,8 +0,0 @@
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: ./build-and-deploy.sh {target}"
echo "Script needs target hostname or ip as parameter"
exit 1
fi
./gradlew clean build jibBuildTar && scp app/build/github-release-bot.tar "$1":/opt/stacks/github-release-bot/

5
go.mod Normal file
View file

@ -0,0 +1,5 @@
module codeberg.org/ryan_harg/github-release-bot
go 1.22.5
require github.com/magefile/mage v1.15.0

2
go.sum Normal file
View file

@ -0,0 +1,2 @@
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=

21
magefile.go Normal file
View file

@ -0,0 +1,21 @@
//go:build mage
package main
import (
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
)
const app = "github-release-bot"
// Builds and exports the application as a docker image tar file.
func build() error {
return sh.RunV("./gradlew", "build", "jibBuildTar")
}
// Deploys the application to a specified host via scp.
func Deploy(host string) error {
mg.Deps(build)
return sh.RunV("scp", "app/build/"+app+".tar", host+":/opt/stacks/"+app+"/")
}