Skip to content

Commit

Permalink
testing: docker ci
Browse files Browse the repository at this point in the history
  • Loading branch information
c-seeger committed Mar 6, 2024
1 parent 6288f30 commit 4a5f40b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v4

- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
go-version: '1.22.x'

- name: Install dependencies
run: |
sudo apt-get install -y git
git clone https://github.com/magefile/mage
cd mage && go run bootstrap.go
cd ..
- name: Docker prerequisites
run: mage docker:init


- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
Expand Down
21 changes: 13 additions & 8 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type (
Service mg.Namespace
Test mg.Namespace
Release mg.Namespace
Docker mg.Namespace
)

// Run - mage run
Expand Down Expand Up @@ -59,7 +60,7 @@ func (t Test) Coverage() error {

// Clean - cleans up the client generation and binarys
func (t Test) Clean() error {
mg.Deps(Release.CleanDocker)
mg.Deps(Docker.CleanDocker)
fmt.Println("cleaning up")
if _, err := os.Stat("coverage.out"); err == nil {
err = os.Remove("coverage.out")
Expand Down Expand Up @@ -118,10 +119,8 @@ func (Release) All() error {
return nil
}

// Docker - creates docker container
func (r Release) Docker() error {
mg.Deps(r.CleanDocker)
mg.Deps(Service.Build)
// Init - initializes docker build requirements
func (Docker) Init() error {
if err := os.MkdirAll(dockerPath+"/conf", 0755); err != nil {
return err
}
Expand All @@ -134,8 +133,14 @@ func (r Release) Docker() error {
return err
}

copyFile(confFile, dockerPath+"/"+confFile, 1000)
return copyFile(confFile, dockerPath+"/"+confFile, 1000)
}

// Docker - creates docker container
func (d Docker) Docker() error {
mg.Deps(d.CleanDocker)
mg.Deps(Service.Build)
mg.Deps(d.Init)
cmd := exec.Command("git", "describe", "--tags")
b, err := cmd.CombinedOutput()
if err != nil {
Expand All @@ -158,8 +163,8 @@ func (r Release) Docker() error {
return sh.RunV("docker", "push", registry+":latest")
}

// CleanDocker - removes docker build files
func (Release) CleanDocker() error {
// Clean - removes docker build files
func (Docker) CleanDocker() error {
if _, err := os.Stat(dockerPath); err == nil {
err = os.RemoveAll(dockerPath)
if err != nil {
Expand Down

0 comments on commit 4a5f40b

Please sign in to comment.