Compare commits
9 Commits
v1.0.1-bet
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dbdab7caaa | ||
|
|
b02b68c668 | ||
|
|
e202c32a31 | ||
|
|
c43a4473ee | ||
|
|
1b936d8431 | ||
|
|
c4cf4aa33e | ||
|
|
bdfc0beb23 | ||
|
|
73da559bf3 | ||
|
|
7c0d7d26e4 |
@ -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
|
||||||
10
Dockerfile
10
Dockerfile
@ -8,15 +8,11 @@ RUN apk add --no-cache git ca-certificates
|
|||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# Copy *both* dependency files first so Docker-layer caching works
|
# Bring in the source (vendor dir included)
|
||||||
COPY go.mod go.sum ./
|
|
||||||
RUN go mod download
|
|
||||||
|
|
||||||
# Bring in the rest of the source
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build static binary
|
# Build static binary using vendored dependencies
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/action ./main.go
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod=vendor -o /out/action ./main.go
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# — Runtime stage —
|
# — Runtime stage —
|
||||||
|
|||||||
@ -9,7 +9,7 @@ runs:
|
|||||||
using: "docker"
|
using: "docker"
|
||||||
image: "Dockerfile"
|
image: "Dockerfile"
|
||||||
env:
|
env:
|
||||||
ISSUE_LABELS: ${{ gitea.event.issue.labels }}
|
ISSUE_LABELS: ${{ join(gitea.event.issue.labels.*.name, ',') }}
|
||||||
ISSUE_NUMBER: ${{ gitea.event.issue.number }}
|
ISSUE_NUMBER: ${{ gitea.event.issue.number }}
|
||||||
ODOO_TICKET_NUMBER: ${{ gitea.event.issue.ref }}
|
ODOO_TICKET_NUMBER: ${{ gitea.event.issue.ref }}
|
||||||
ISSUE_TITLE: ${{ gitea.event.issue.title }}
|
ISSUE_TITLE: ${{ gitea.event.issue.title }}
|
||||||
|
|||||||
18
main.go
18
main.go
@ -7,7 +7,6 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"reflect"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -30,8 +29,10 @@ func main() {
|
|||||||
logger.Printf("ODOO_TICKET_NUMBER: %s\n", issueOdooTicketString)
|
logger.Printf("ODOO_TICKET_NUMBER: %s\n", issueOdooTicketString)
|
||||||
|
|
||||||
issueTitle := os.Getenv("ISSUE_TITLE")
|
issueTitle := os.Getenv("ISSUE_TITLE")
|
||||||
|
|
||||||
labelsEnv := os.Getenv("ISSUE_LABELS")
|
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")
|
issueNumberString := os.Getenv("ISSUE_NUMBER")
|
||||||
|
|
||||||
giteaToken := os.Getenv("GITEA_TOKEN")
|
giteaToken := os.Getenv("GITEA_TOKEN")
|
||||||
@ -114,8 +115,17 @@ func main() {
|
|||||||
logger.Printf("Branch '%s' already exists. No action taken.\n", branchName)
|
logger.Printf("Branch '%s' already exists. No action taken.\n", branchName)
|
||||||
} else {
|
} else {
|
||||||
// Create and push the branch
|
// Create and push the branch
|
||||||
logger.Printf("Creating branch '%s' from 'develop'.\n", branchName)
|
originBranch := "origin/develop"
|
||||||
err = runCommand(logger, "git", "checkout", "-b", branchName, "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 {
|
if err != nil {
|
||||||
logger.Printf("Error while creating the branch: %v\n", err)
|
logger.Printf("Error while creating the branch: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user