ADD test
This commit is contained in:
parent
7308a1d113
commit
269fd8f5c5
121
.github/workflows/test_project.yml
vendored
121
.github/workflows/test_project.yml
vendored
@ -1,105 +1,68 @@
|
|||||||
name: ${{ github.actor }} executed Build Push Prod
|
name: "dev test"
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
branches:
|
||||||
- 'v[0-9]+\.[0-9]+\.[0-9]+'
|
- master
|
||||||
|
- dev
|
||||||
|
- 'feature/**'
|
||||||
|
paths:
|
||||||
|
- '**.go'
|
||||||
|
- '**.yml'
|
||||||
|
- '**.yaml'
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.TOKEN }}
|
TOKEN: ${{ secrets.TOKEN }}
|
||||||
USERNAME: ${{ vars.USERNAME }}
|
USERNAME: ${{ vars.USERNAME }}
|
||||||
TAG_VERSION: ${{ github.ref_name }}
|
TAG_VERSION: ${{ github.ref_name }}
|
||||||
steps:
|
steps:
|
||||||
- name: echo repo dir
|
|
||||||
id: repo-url
|
|
||||||
run: |
|
|
||||||
echo "repourl=$(echo ${{ github.server_url }} | sed -e 's;https://;;')" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Quemu
|
- name: Setup Go
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: actions/setup-go@v5
|
||||||
|
|
||||||
- name: Set Up BuildX
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Login to Docker
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
with:
|
||||||
registry: https://git.maximotejeda.com
|
go-version-file: 'go.mod'
|
||||||
username: ${{ vars.USERNAME }}
|
- name: run tidy
|
||||||
password: ${{ secrets.PWD }}
|
|
||||||
|
|
||||||
- name: calculate short sha
|
|
||||||
id: calculate-sha
|
|
||||||
run: |
|
run: |
|
||||||
echo "shortsha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
go mod tidy
|
||||||
|
- name: test with go
|
||||||
|
run: go test -v ./...
|
||||||
|
|
||||||
- name: Build and push
|
vulnCheck:
|
||||||
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
|
runs-on: ubuntu-latest
|
||||||
needs: build
|
needs: test
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.TOKEN }}
|
TOKEN: ${{ secrets.TOKEN }}
|
||||||
TAG: ${{ github.ref_name }}
|
|
||||||
PASSWORD: $PWD
|
|
||||||
USERNAME: ${{ vars.USERNAME }}
|
USERNAME: ${{ vars.USERNAME }}
|
||||||
TAG_VERSION: ${{ github.ref_name }}
|
TAG_VERSION: ${{ github.ref_name }}
|
||||||
NATS_SERVICE_URL: "${{ vars.NATS_SERVICE_URL }}"
|
|
||||||
ENV: "production"
|
|
||||||
APPLICATION_PORT: "${{ vars.APPLICATION_PORT }}"
|
|
||||||
DATA_SOURCE_URL: "${{ vars.DATA_SOURCE_URL }}"
|
|
||||||
steps:
|
steps:
|
||||||
- name: echo repo dir
|
- name: checkout Code
|
||||||
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
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: install envsubst
|
- name: go vuln check
|
||||||
run: |
|
uses: golang/govulncheck-action@v1
|
||||||
apt update
|
with:
|
||||||
apt install -y gettext-base
|
go-version-file: 'go.mod'
|
||||||
apt clean
|
go-package: ./...
|
||||||
|
|
||||||
- name: create deployment files
|
Ci-Lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: vulnCheck
|
||||||
env:
|
env:
|
||||||
IMAGE: "${{ steps.repo-url.outputs.repourl }}/${{ github.repository }}:${{ github.ref_name }}"
|
TOKEN: ${{ secrets.TOKEN }}
|
||||||
REPONAME: "${{ steps.repo-url.outputs.repoName }}"
|
USERNAME: ${{ vars.USERNAME }}
|
||||||
run: |
|
TAG_VERSION: ${{ github.ref_name }}
|
||||||
envsubst < k8s/deployment.yml.template > k8s/deployment.yml
|
steps:
|
||||||
- name: Download kubectl
|
- name: Checkout code
|
||||||
run: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: install kubectl
|
- name: Setup Go
|
||||||
run: sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
- name: insert kube config
|
go-version-file: 'go.mod'
|
||||||
run: |
|
- name: CI lint Check
|
||||||
mkdir ~/.kube
|
uses: golangci/golangci-lint-action@v6
|
||||||
export IMAGE="$( echo ${{ github.server_url }} | sed -e 's;https://;;')/${{ github.repository }}:${{ github.ref_name }}"
|
with:
|
||||||
echo "${{ secrets.KUBECONFIG }}" > ~/.kube/config
|
only-new-issues: true
|
||||||
- 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 }}-grpc --replicas=0
|
|
||||||
|
|
||||||
- name: scale up deployment
|
|
||||||
run: kubectl scale deployment ${{ steps.repo-url.outputs.repoName }}-grpc --replicas=1
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user