Restructured workflow added
This commit is contained in:
parent
40dceb78c8
commit
3888c47d17
@ -1,19 +0,0 @@
|
||||
name: Gitea Actions Demo
|
||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
Explore-Gitea-Actions:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "🎉 The job was automatically and automagically triggered by a ${{ gitea.event_name }} event."
|
||||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||
- name: List files in the repository
|
||||
run: |
|
||||
ls ${{ gitea.workspace }}
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
106
.github/workflows/image_creation.yml
vendored
Normal file
106
.github/workflows/image_creation.yml
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
name: ${{ github.actor }} executed Build Push Prod
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v[0-9]+\.[0-9]+\.[0-9]+'
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TOKEN: ${{ secrets.TOKEN }}
|
||||
USERNAME: ${{ vars.USERNAME }}
|
||||
TAG_VERSION: ${{ github.ref_name }}
|
||||
steps:
|
||||
- name: echo repo dir
|
||||
id: repo-url
|
||||
run: |
|
||||
echo "repourl=$(echo ${{ github.server_url }} | sed -e 's;https://;;')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Quemu
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set Up BuildX
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: https://git.maximotejeda.com
|
||||
username: ${{ vars.USERNAME }}
|
||||
password: ${{ secrets.PWD }}
|
||||
|
||||
- name: calculate short sha
|
||||
id: calculate-sha
|
||||
run: |
|
||||
echo "shortsha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: "${{ steps.repo-url.outputs.repourl }}/${{ github.repository }}:${{ github.ref_name }}"
|
||||
build-args: |
|
||||
version=${{ github.ref_name }}
|
||||
SHORTSHA=${{ steps.calculate-sha.outputs.shortsha }}
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
env:
|
||||
TOKEN: ${{ secrets.TOKEN }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
PASSWORD: $PWD
|
||||
USERNAME: ${{ vars.USERNAME }}
|
||||
TAG_VERSION: ${{ github.ref_name }}
|
||||
NATS_SERVICE_URL: "${{ vars.NATS_SERVICE_URL }}"
|
||||
ENV: "{{ vars.ENV }}"
|
||||
APPLICATION_PORT: "${{ vars.APPLICATION_PORT }}"
|
||||
APPLICATION_HOST: "${{ vars.APPLICATION_HOST }}"
|
||||
DOLLAR_SERVICE_URL: "${{ vars.DOLLAR_SERVICE_URL }}"
|
||||
steps:
|
||||
- name: echo repo dir
|
||||
id: repo-url
|
||||
run: |
|
||||
echo "repourl=$(echo ${{ github.server_url }} | sed -e 's;https://;;')" >> $GITHUB_OUTPUT
|
||||
echo "repoName=$(echo ${{ github.repository }} | sed -e 's;${{ github.actor }}/;;')" >> $GITHUB_OUTPUT
|
||||
echo "${{ github.repository }} | sed -e 's;${{ github.actor }}/;;')"
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: install envsubst
|
||||
run: |
|
||||
apt update
|
||||
apt install -y gettext-base
|
||||
apt clean
|
||||
|
||||
- name: create deployment files
|
||||
env:
|
||||
IMAGE: "${{ steps.repo-url.outputs.repourl }}/${{ github.repository }}:${{ github.ref_name }}"
|
||||
REPONAME: "${{ steps.repo-url.outputs.repoName }}"
|
||||
run: |
|
||||
envsubst < k8s/deployment.yml.template > k8s/deployment.yml
|
||||
- name: Download kubectl
|
||||
run: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||
|
||||
- name: install kubectl
|
||||
run: sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
||||
|
||||
- name: insert kube config
|
||||
run: |
|
||||
mkdir ~/.kube
|
||||
export IMAGE="$( echo ${{ github.server_url }} | sed -e 's;https://;;')/${{ github.repository }}:${{ github.ref_name }}"
|
||||
echo "${{ secrets.KUBECONFIG }}" > ~/.kube/config
|
||||
- name: check pod
|
||||
run: kubectl apply -f k8s/deployment.yml
|
||||
|
||||
- name: scale down deployment
|
||||
continue-on-error: true
|
||||
run: kubectl scale deployment ${{ steps.repo-url.outputs.repoName }} --replicas=0
|
||||
|
||||
- name: scale up deployment
|
||||
run: kubectl scale deployment ${{ steps.repo-url.outputs.repoName }} --replicas=1
|
||||
68
.github/workflows/test_project.yml
vendored
Normal file
68
.github/workflows/test_project.yml
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
name: "dev test"
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- dev
|
||||
- 'feature/**'
|
||||
paths:
|
||||
- '**.go'
|
||||
- '**.yml'
|
||||
- '**.yaml'
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
TOKEN: ${{ secrets.TOKEN }}
|
||||
USERNAME: ${{ vars.USERNAME }}
|
||||
TAG_VERSION: ${{ github.ref_name }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
- name: run tidy
|
||||
run: |
|
||||
go mod tidy
|
||||
- name: test with go
|
||||
run: go test -v ./...
|
||||
|
||||
vulnCheck:
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
env:
|
||||
TOKEN: ${{ secrets.TOKEN }}
|
||||
USERNAME: ${{ vars.USERNAME }}
|
||||
TAG_VERSION: ${{ github.ref_name }}
|
||||
steps:
|
||||
- name: checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: go vuln check
|
||||
uses: golang/govulncheck-action@v1
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
go-package: ./...
|
||||
|
||||
Ci-Lint:
|
||||
runs-on: ubuntu-latest
|
||||
needs: vulnCheck
|
||||
env:
|
||||
TOKEN: ${{ secrets.TOKEN }}
|
||||
USERNAME: ${{ vars.USERNAME }}
|
||||
TAG_VERSION: ${{ github.ref_name }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
- name: CI lint Check
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
only-new-issues: true
|
||||
2
Makefile
2
Makefile
@ -38,7 +38,7 @@ run-local:clean build
|
||||
@bin/$(BINAME)
|
||||
|
||||
build:
|
||||
@mkdir dolardb || true
|
||||
# @mkdir dolardb || true
|
||||
@env GOOS=$(OS) GOARCH=$(arch) go build -o ./bin/$(BINAME) ./cmd/api/.
|
||||
@env GOOS=$(OS) GOARCH=arm64 go build -o ./bin/$(BINAMEARM) ./cmd/api/.
|
||||
|
||||
|
||||
@ -8,10 +8,10 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"git.maximotejeda.com/maximo/us-dop-api/adapters/dolar"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/internal/adapters/dolar"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/config"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/handlers"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/middlewares"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/internal/handlers"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/internal/middlewares"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/static"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.maximotejeda.com/maximo/dolar/proto/golang/dolar"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/domain"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/internal/domain"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@ -6,8 +6,8 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"git.maximotejeda.com/maximo/us-dop-api/domain"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/ports"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/internal/domain"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/internal/ports"
|
||||
|
||||
)
|
||||
|
||||
@ -9,8 +9,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.maximotejeda.com/maximo/us-dop-api/domain"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/helpers"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/internal/domain"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/internal/helpers"
|
||||
)
|
||||
|
||||
// handler to parse query to the api
|
||||
@ -7,8 +7,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.maximotejeda.com/maximo/us-dop-api/handlers/api"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/ports"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/internal/handlers/api"
|
||||
"git.maximotejeda.com/maximo/us-dop-api/internal/ports"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -1,6 +1,6 @@
|
||||
package ports
|
||||
|
||||
import "git.maximotejeda.com/maximo/us-dop-api/domain"
|
||||
import "git.maximotejeda.com/maximo/us-dop-api/internal/domain"
|
||||
|
||||
type DolarService interface {
|
||||
GetLatest(name string) (*domain.History, error)
|
||||
@ -1,51 +1,44 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: us-dop-api
|
||||
name: $REPONAME
|
||||
labels:
|
||||
app: us-dop-api
|
||||
app: $REPONAME
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: us-dop-api
|
||||
app: $REPONAME
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: us-dop-api
|
||||
name: us-dop-api
|
||||
app: $REPONAME
|
||||
name: $REPONAME
|
||||
spec:
|
||||
containers:
|
||||
- name: us-dop-pi
|
||||
image: localhost:32000/us-dop-api:latest
|
||||
- name: $REPONAME
|
||||
image: $IMAGE
|
||||
env:
|
||||
- name: DOLLAR_SERVICE_URL
|
||||
value: "dolar-grpc-svc:80"
|
||||
value: "$DOLLAR_SERVICE_URL"
|
||||
- name: HOST
|
||||
value: "0.0.0.0"
|
||||
value: "$HOST"
|
||||
- name: NATSURI
|
||||
value: "nats://nats-svc:4222"
|
||||
value: "$NATS_SERVICE_URL"
|
||||
- name: PORT
|
||||
value: "8080"
|
||||
volumeMounts:
|
||||
- name: database
|
||||
mountPath: /app/dolardb
|
||||
volumes:
|
||||
- name: database
|
||||
persistentVolumeClaim:
|
||||
claimName: bank-crawler-pvc
|
||||
value: "$PORT"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: us-dop-api-svc
|
||||
name: $REPONAME-svc
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
selector:
|
||||
app: us-dop-api
|
||||
app: $REPONAME
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 8080
|
||||
targetPort: $PORT
|
||||
name: frontend
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
@ -54,7 +47,7 @@ metadata:
|
||||
annotations:
|
||||
# add an annotation indicating the issuer to use.
|
||||
cert-manager.io/cluster-issuer: letsencrypt
|
||||
name: us-dop-api-ingress
|
||||
name: $REPONAME-ingress
|
||||
spec:
|
||||
rules:
|
||||
- host: cambio.maximotejeda.com
|
||||
@ -64,10 +57,10 @@ spec:
|
||||
path: "/"
|
||||
backend:
|
||||
service:
|
||||
name: us-dop-api-svc
|
||||
name: $REPONAME-svc
|
||||
port:
|
||||
number: 80
|
||||
tls: # < placing a host in the TLS config will determine what ends up in the cert's subjectAltNames
|
||||
- hosts:
|
||||
- cambio.maximotejeda.com
|
||||
secretName: cambio.maximotejeda-cert # < cert-manager will store the created certificate in this secret.
|
||||
#tls: # < placing a host in the TLS config will determine what ends up in the cert's subjectAltNames
|
||||
#- hosts:
|
||||
# - cambio.maximotejeda.com
|
||||
# secretName: cambio.maximotejeda-cert # < cert-manager will store the created certificate in this secret.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user