ci: deployment rules for gitea
This commit is contained in:
parent
69561505ba
commit
e452f21c9b
24
.gitea/workflows/deploy.yml
Normal file
24
.gitea/workflows/deploy.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
name: Deploy
|
||||||
|
run-name: ${{ gitea.actor }} build image and push to container registry
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'main'
|
||||||
|
- 'staging'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
CreateImage:
|
||||||
|
runs-on: [hubstaging]
|
||||||
|
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/build-image.yml@v1.1.6-p
|
||||||
|
with:
|
||||||
|
runner: hubstaging
|
||||||
|
secrets:
|
||||||
|
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
||||||
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
DeployService:
|
||||||
|
runs-on: [hubstaging]
|
||||||
|
needs: CreateImage
|
||||||
|
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/deploy.yml@v1.1.4-p7
|
||||||
|
with:
|
||||||
|
runner: hubstaging
|
14
.gitea/workflows/lint.yml
Normal file
14
.gitea/workflows/lint.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
name: Lint
|
||||||
|
run-name: ${{ gitea.actor }} produce linting
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'dev'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Lint:
|
||||||
|
runs-on: [hubstaging]
|
||||||
|
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/lint.yml@v1.1.2
|
||||||
|
with:
|
||||||
|
runner: hubstaging
|
@ -1,89 +0,0 @@
|
|||||||
include:
|
|
||||||
- project: "devops/pena-continuous-integration"
|
|
||||||
file: "/templates/docker/build-template.gitlab-ci.yml"
|
|
||||||
- project: "devops/pena-continuous-integration"
|
|
||||||
file: "/templates/docker/clean-template.gitlab-ci.yml"
|
|
||||||
- project: "devops/pena-continuous-integration"
|
|
||||||
file: "/templates/docker/deploy-template.gitlab-ci.yml"
|
|
||||||
|
|
||||||
stages:
|
|
||||||
# - lint
|
|
||||||
# - test
|
|
||||||
- clean
|
|
||||||
- build
|
|
||||||
- deploy
|
|
||||||
|
|
||||||
#lint:
|
|
||||||
# image: golangci/golangci-lint:v1.53.3-alpine
|
|
||||||
# stage: lint
|
|
||||||
# before_script:
|
|
||||||
# - echo GITLAB_TOKEN = $GITLAB_TOKEN
|
|
||||||
# - git config --global url."https://forgomod:${GITLAB_TOKEN}@penahub.gitlab.yandexcloud.net/".insteadOf "https://penahub.gitlab.yandexcloud.net/"
|
|
||||||
# - export GOPRIVATE=penahub.gitlab.yandexcloud.net/backend/penahub_common/
|
|
||||||
# - go install github.com/vektra/mockery/v2@v2.26.0
|
|
||||||
# - go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.4
|
|
||||||
# script:
|
|
||||||
# - go generate ./...
|
|
||||||
# - golangci-lint version
|
|
||||||
# - golangci-lint run ./...
|
|
||||||
#
|
|
||||||
# test:
|
|
||||||
# image: golang:1.20.3-alpine
|
|
||||||
# stage: test
|
|
||||||
# coverage: /\(statements\)(?:\s+)?(\d+(?:\.\d+)?%)/
|
|
||||||
# script:
|
|
||||||
# - CGO_ENABLED=0 go test ./... -coverprofile=coverage.out
|
|
||||||
# - go tool cover -html=coverage.out -o coverage.html
|
|
||||||
# - go tool cover -func coverage.out
|
|
||||||
# artifacts:
|
|
||||||
# expire_in: "3 days"
|
|
||||||
# paths:
|
|
||||||
# - coverage.html
|
|
||||||
|
|
||||||
clear-old-images:
|
|
||||||
extends: .clean_template
|
|
||||||
variables:
|
|
||||||
STAGING_BRANCH: "main"
|
|
||||||
PRODUCTION_BRANCH: "main"
|
|
||||||
image:
|
|
||||||
name: docker/compose:1.28.0
|
|
||||||
entrypoint: [""]
|
|
||||||
before_script:
|
|
||||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
|
||||||
- docker images
|
|
||||||
script:
|
|
||||||
- docker system prune -af
|
|
||||||
|
|
||||||
build-app:
|
|
||||||
stage: build
|
|
||||||
before_script:
|
|
||||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
|
||||||
- echo STAGING_BRANCH = $STAGING_BRANCH
|
|
||||||
- echo CI_REGISTRY = $CI_REGISTRY
|
|
||||||
- echo CI_REGISTRY_USER = $CI_REGISTRY_USER
|
|
||||||
- echo CI_PROJECT_DIR = $CI_PROJECT_DIR
|
|
||||||
- echo CI_REGISTRY_IMAGE = $CI_REGISTRY_IMAGE
|
|
||||||
- echo CI_COMMIT_REF_SLUG = $CI_COMMIT_REF_SLUG
|
|
||||||
- echo DOCKER_BUILD_PATH = $DOCKER_BUILD_PATH
|
|
||||||
- echo CI_PIPELINE_ID = $CI_PIPELINE_ID
|
|
||||||
- echo JWT_SECRET = $JWT_SECRET
|
|
||||||
|
|
||||||
variables:
|
|
||||||
DOCKER_BUILD_PATH: "build/Dockerfile"
|
|
||||||
PRODUCTION_BRANCH: main
|
|
||||||
STAGING_BRANCH: "staging"
|
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_BRANCH == $PRODUCTION_BRANCH || $CI_COMMIT_BRANCH == $STAGING_BRANCH
|
|
||||||
|
|
||||||
script:
|
|
||||||
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID --build-arg GITLAB_TOKEN=$GITLAB_TOKEN $CI_PROJECT_DIR
|
|
||||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
|
|
||||||
|
|
||||||
|
|
||||||
deploy-to-staging:
|
|
||||||
extends: .deploy_template
|
|
||||||
variables:
|
|
||||||
DEPLOY_TO: "staging"
|
|
||||||
BRANCH: "staging"
|
|
||||||
after_script:
|
|
||||||
- docker system prune --all --volumes --force
|
|
@ -1,14 +1,11 @@
|
|||||||
FROM golang:alpine as build
|
FROM gitea.pena/penadevops/container-images/golang:main as build
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ARG GITLAB_TOKEN
|
|
||||||
RUN apk add git
|
RUN apk add git
|
||||||
ENV GOPRIVATE=penahub.gitlab.yandexcloud.net/backend/penahub_common
|
|
||||||
RUN git config --global url."https://buildToken:glpat-axA8ttckx3aPf_xd2Dym@penahub.gitlab.yandexcloud.net/".insteadOf "https://penahub.gitlab.yandexcloud.net/"
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app
|
||||||
|
|
||||||
FROM alpine
|
FROM gitea.pena/penadevops/container-images/alpine:main
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
COPY --from=build app /
|
COPY --from=build app /
|
||||||
COPY static static
|
COPY static static
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
services:
|
services:
|
||||||
templategen:
|
templategen:
|
||||||
container_name: templategen_service
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
|
image: gitea.pena:3000/penaside/docxtemplater/staging:$GITHUB_RUN_NUMBER
|
||||||
hostname: templategen_service
|
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- 10.7.0.6:8012:80
|
||||||
- "443:443"
|
- 10.7.0.6:8443:443
|
||||||
environment:
|
environment:
|
||||||
MONGO_URL: mongodb://$MONGO_USER:$MONGO_PASSWORD@10.8.0.6:27017/?authSource=templategen
|
MONGO_URL: mongodb://templategen:54143ffdd9304865586e5cf1@10.7.0.6:27017/?authSource=templategen
|
||||||
PENADISK_URL: $PENADISK_URL
|
PENADISK_URL: http://10.7.0.6:8011/
|
||||||
PRIVILEGES_DOMAIN: https://admin.pena.digital/strator
|
PRIVILEGES_DOMAIN: https://admin.pena.digital/strator
|
||||||
KAFKA_BROKERS: 10.8.0.6:9092
|
KAFKA_BROKERS: 10.7.0.6:9092
|
||||||
KAFKA_TARIFF_TOPIC: tariffs
|
KAFKA_TARIFF_TOPIC: tariffs
|
||||||
KAFKA_CONSUMER_GROUP_ID: templategen1
|
KAFKA_CONSUMER_GROUP_ID: templategen1
|
||||||
EMAIL_HOST: connect.mailclient.bz
|
EMAIL_HOST: connect.mailclient.bz
|
||||||
|
Loading…
Reference in New Issue
Block a user