Compare commits

...

9 Commits
v1.1 ... main

Author SHA1 Message Date
Mandresy RABENJAHARISON
dbdab7caaa Merge branch 'release/v1.0.1' 2025-09-29 17:32:29 +03:00
Mandresy RABENJAHARISON
b02b68c668 fix: update branch creation action to use 'develop' instead of 'main' 2025-09-29 17:31:09 +03:00
Mandresy RABENJAHARISON
e202c32a31 fix: update branch creation workflow to use specific action URL 2025-09-29 17:27:04 +03:00
Mandresy RABENJAHARISON
c43a4473ee fix: specify 'main' as default ref and enable clean checkout in branch creation workflow 2025-09-29 17:21:18 +03:00
Mandresy RABENJAHARISON
1b936d8431 feat: log prefix and enhance handling for branch creation 2025-09-29 17:07:55 +03:00
Mandresy RABENJAHARISON
c4cf4aa33e feat: support branch creation from 'main' for hotfixes and handle reopened issues in workflow 2025-09-29 17:01:50 +03:00
Mandresy RABENJAHARISON
bdfc0beb23 feat: add workflow to create and link branch for new issues 2025-09-29 16:44:43 +03:00
Mandresy RABENJAHARISON
73da559bf3 chore: optimize Dockerfile layers and remove unused reflect import 2025-09-29 15:41:33 +03:00
Mandresy RABENJAHARISON
7c0d7d26e4 fix: correct ISSUE_LABELS parsing and logging 2025-09-29 15:30:08 +03:00
4 changed files with 38 additions and 12 deletions

View File

@ -0,0 +1,20 @@
name: Create a new branch and link it back to the issue.
on:
issues:
types:
- opened
- reopened
jobs:
create-branch:
runs-on: node1-runner-timesheet1
steps:
- name: Checkout Repository
uses: actions/checkout@v3
clean: 'true'
ref: 'main'
- name: Create a New Branch and Link to Issue
uses: https://gitea.ethumada.com/gitea/new-issue-branch@develop

View File

@ -8,15 +8,11 @@ RUN apk add --no-cache git ca-certificates
WORKDIR /src
# Copy *both* dependency files first so Docker-layer caching works
COPY go.mod go.sum ./
RUN go mod download
# Bring in the rest of the source
# Bring in the source (vendor dir included)
COPY . .
# Build static binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/action ./main.go
# Build static binary using vendored dependencies
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod=vendor -o /out/action ./main.go
########################
# — Runtime stage —

View File

@ -9,7 +9,7 @@ runs:
using: "docker"
image: "Dockerfile"
env:
ISSUE_LABELS: ${{ gitea.event.issue.labels }}
ISSUE_LABELS: ${{ join(gitea.event.issue.labels.*.name, ',') }}
ISSUE_NUMBER: ${{ gitea.event.issue.number }}
ODOO_TICKET_NUMBER: ${{ gitea.event.issue.ref }}
ISSUE_TITLE: ${{ gitea.event.issue.title }}

18
main.go
View File

@ -7,7 +7,6 @@ import (
"log"
"os"
"os/exec"
"reflect"
"strconv"
"strings"
@ -30,8 +29,10 @@ func main() {
logger.Printf("ODOO_TICKET_NUMBER: %s\n", issueOdooTicketString)
issueTitle := os.Getenv("ISSUE_TITLE")
labelsEnv := os.Getenv("ISSUE_LABELS")
logger.Printf("ISSUE_TITLE: %s\n", reflect.TypeOf(labelsEnv))
logger.Printf("ISSUE_LABELS: %s\n", labelsEnv)
issueNumberString := os.Getenv("ISSUE_NUMBER")
giteaToken := os.Getenv("GITEA_TOKEN")
@ -114,8 +115,17 @@ func main() {
logger.Printf("Branch '%s' already exists. No action taken.\n", branchName)
} else {
// Create and push the branch
logger.Printf("Creating branch '%s' from 'develop'.\n", branchName)
err = runCommand(logger, "git", "checkout", "-b", branchName, "origin/develop")
originBranch := "origin/develop"
logger.Printf("Prefix is : %s", prefix)
if prefix == "hotfix" {
originBranch = "origin/main"
} else {
logger.Printf("hotfix != %s", prefix)
}
logger.Printf("Creating branch '%s' from '%s'.\n", branchName, originBranch)
err = runCommand(logger, "git", "checkout", "-b", branchName, originBranch)
if err != nil {
logger.Printf("Error while creating the branch: %v\n", err)
os.Exit(1)