Skip to content

Commit

Permalink
Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
andreekuriks committed Nov 18, 2024
1 parent f294b49 commit 020daf2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build

on:
push:
branches: [ main, argocd-integration, build_improvments ]
branches: [ main, argocd-integration, build_improvments, debugging ]
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -49,7 +49,6 @@ jobs:
images: entigolabs/entigo-k8s-gitops
tags: |
type=raw,value={{branch}}-${{ github.run_number }}
type=raw,value={{branch}}-latest
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
Expand All @@ -59,7 +58,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Create Release
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/debugging'
id: create_release
uses: actions/create-release@v1
env:
Expand All @@ -72,7 +71,7 @@ jobs:
draft: true
prerelease: false
- name: Upload Release Artifact
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/debugging'
id: upload_release_asset
uses: actions/upload-release-asset@v1
env:
Expand Down
12 changes: 12 additions & 0 deletions internal/app/gitops/git/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (r *Repository) Pull() error {

func (r *Repository) Push() error {
pushOptions := r.getPushOptions()
common.Logger.Println(fmt.Sprintf("pushOptions RemoteName: %s, RemoteURL: %s", pushOptions.RemoteName, pushOptions.RemoteURL))
err := r.Repository.Push(pushOptions)
if err != nil {
return handlePushErr(err)
Expand All @@ -60,6 +61,7 @@ func (r *Repository) Push() error {
}

func (r *Repository) OpenGitOpsRepo() {
common.Logger.Println("In OpenGitOpsRepo method")
repo, err := git.PlainOpen(common.GetRepositoryRootPath(r.Repo))
if err != nil {
common.Logger.Fatal(&common.PrefixedError{Reason: err})
Expand All @@ -68,6 +70,7 @@ func (r *Repository) OpenGitOpsRepo() {
}

func (r *Repository) Add() {
common.Logger.Println("In repository.go Add method")
wt := r.getWorkTree()
_, err := wt.Add(".")
if err != nil {
Expand All @@ -76,12 +79,17 @@ func (r *Repository) Add() {
}

func (r *Repository) gitCommit() {
common.Logger.Println("In gitCommit method")
cfg := r.getGitConfig()
common.Logger.Println(fmt.Sprintf("cfg.Core.Worktree: %s", cfg.Core.Worktree))
// common.Logger.Println(fmt.Sprintf("cfg.Core.Worktree: %s", cfg.URLs[0].Name))
wt := r.getWorkTree()
commitMessage, msgErr := r.getCommitMessage()
common.Logger.Println(fmt.Sprintf("commitMessage: %s", commitMessage))
if msgErr != nil {
common.Logger.Fatal(&common.PrefixedError{Reason: msgErr})
}
common.Logger.Println("Starting to produce commit at wt.Commit")
commit, commitErr := wt.Commit(commitMessage, &git.CommitOptions{
All: true,
Author: &object.Signature{
Expand All @@ -93,6 +101,7 @@ func (r *Repository) gitCommit() {
if commitErr != nil {
common.Logger.Fatal(&common.PrefixedError{Reason: commitErr})
}
common.Logger.Println("Starting to commit at r.Repository.CommitObject")
_, commitObjErr := r.Repository.CommitObject(commit)
if commitObjErr != nil {
common.Logger.Fatal(&common.PrefixedError{Reason: commitObjErr})
Expand Down Expand Up @@ -121,7 +130,9 @@ func (r *Repository) getGitConfig() *config.Config {
}

func (r *Repository) CommitIfModified() {
common.Logger.Println("In CommitIfModified method")
if r.isRepoModified() {
common.Logger.Println("Repo is modified, starting with gitCommit method")
r.gitCommit()
} else {
common.Logger.Println("nothing to commit, working tree clean")
Expand All @@ -146,6 +157,7 @@ func getGitStatus(wt *git.Worktree) git.Status {
}

func (r *Repository) getWorkTree() *git.Worktree {
common.Logger.Println("In getWorkTree method")
wt, err := r.Repository.Worktree()
if err != nil {
common.Logger.Fatal(&common.PrefixedError{Reason: err})
Expand Down

0 comments on commit 020daf2

Please sign in to comment.