56
Some checks failed
Deploy Production / Deploy to Staging (push) Has been skipped
Go Linter / Build golang services (api_gateway) (push) Has been cancelled
Go Linter / Push Docker Images (api_gateway) (push) Has been cancelled
Go Linter / Run golangci-lint (api_gateway) (push) Has been cancelled
Some checks failed
Deploy Production / Deploy to Staging (push) Has been skipped
Go Linter / Build golang services (api_gateway) (push) Has been cancelled
Go Linter / Push Docker Images (api_gateway) (push) Has been cancelled
Go Linter / Run golangci-lint (api_gateway) (push) Has been cancelled
This commit is contained in:
@@ -1,86 +1,134 @@
|
|||||||
# name: Go Linter
|
name: Go Linter
|
||||||
|
|
||||||
# on:
|
on:
|
||||||
# pull_request:
|
pull_request:
|
||||||
# branches:
|
branches:
|
||||||
# - master
|
- master
|
||||||
# push:
|
- release
|
||||||
# branches:
|
push:
|
||||||
# - master
|
branches:
|
||||||
|
- master
|
||||||
|
- release
|
||||||
|
|
||||||
# jobs:
|
jobs:
|
||||||
# lint:
|
lint:
|
||||||
# name: Run golangci-lint
|
name: Run golangci-lint
|
||||||
# runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
# strategy:
|
strategy:
|
||||||
# matrix:
|
matrix:
|
||||||
# project:
|
project:
|
||||||
# - api_gateway
|
- api_gateway
|
||||||
|
|
||||||
# steps:
|
steps:
|
||||||
# - name: Checkout repository
|
- name: Checkout repository
|
||||||
# uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# - name: Set up Go
|
- name: Set up Go
|
||||||
# uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
# with:
|
with:
|
||||||
# go-version: 1.23
|
go-version: 1.23
|
||||||
|
|
||||||
# - name: Install golangci-lint
|
- name: Install golangci-lint
|
||||||
# run: |
|
run: |
|
||||||
# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.2
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.2
|
||||||
|
|
||||||
# - name: Run golangci-lint
|
- name: Run golangci-lint
|
||||||
# run: |
|
run: |
|
||||||
# go mod tidy
|
go mod tidy
|
||||||
# golangci-lint run -c ./.golangci-lint.yaml --fix=false --color=always
|
golangci-lint run -c ./.golangci-lint.yaml --fix=false --color=always
|
||||||
|
|
||||||
# build:
|
build:
|
||||||
# name: Build golang services
|
name: Build golang services
|
||||||
# runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
# needs: lint
|
needs: lint
|
||||||
|
|
||||||
# strategy:
|
strategy:
|
||||||
# matrix:
|
matrix:
|
||||||
# project:
|
project:
|
||||||
# - api_gateway
|
- api_gateway
|
||||||
|
|
||||||
# steps:
|
steps:
|
||||||
# - name: Checkout repository
|
- name: Checkout repository
|
||||||
# uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# - name: Set up Go
|
- name: Set up Go
|
||||||
# uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
# with:
|
with:
|
||||||
# go-version: 1.23
|
go-version: 1.23
|
||||||
|
|
||||||
# - name: Build golang services
|
- name: Build golang services
|
||||||
# run: |
|
run: |
|
||||||
# go mod tidy
|
go mod tidy
|
||||||
# CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o main cmd/main.go
|
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o main cmd/main.go
|
||||||
|
|
||||||
# push:
|
push:
|
||||||
# name: Push Docker Images
|
name: Push Docker Images
|
||||||
# runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
# needs: lint
|
needs: lint
|
||||||
# if: gitea.ref == 'refs/heads/master'
|
if: ${{ gitea.ref == 'refs/heads/master' || gitea.ref == 'refs/heads/release' }}
|
||||||
|
|
||||||
# strategy:
|
strategy:
|
||||||
# matrix:
|
matrix:
|
||||||
# project:
|
project:
|
||||||
# - api_gateway
|
- api_gateway
|
||||||
|
|
||||||
# steps:
|
steps:
|
||||||
# - name: Checkout репозитория
|
- name: Checkout репозитория
|
||||||
# uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# - name: Build and Push
|
- name: Extract Git metadata
|
||||||
# env:
|
id: git-metadata
|
||||||
# SECDIST_CONFIG: ${{ secrets.FMT_CRM_SECDIST_CONFIG }}
|
env:
|
||||||
# run: |
|
REPO: ${{ github.repository }}
|
||||||
# echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
run: |
|
||||||
# IMAGE_NAME="molvaapp/${{ matrix.project }}"
|
GIT_SHA=$(git rev-parse --short HEAD)
|
||||||
# TAG="latest"
|
GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo 'none')
|
||||||
# docker build -t $IMAGE_NAME:$TAG .
|
TARGET_ENV=${{ github.ref == 'refs/heads/release' && 'staging' || 'production' }}
|
||||||
# docker push $IMAGE_NAME:$TAG
|
|
||||||
|
echo "GIT_SHA=${GIT_SHA}" >> $GITHUB_OUTPUT
|
||||||
|
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT
|
||||||
|
echo "TARGET_ENV=${TARGET_ENV}" >> $GITHUB_OUTPUT
|
||||||
|
echo "REPO_NAME=$(echo $REPO | cut -d'/' -f2)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Login to Docker Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Extract image metadata
|
||||||
|
id: docker-metadata
|
||||||
|
needs: git-metadata
|
||||||
|
env:
|
||||||
|
REGISTRY: hub.docker.com
|
||||||
|
REPO_NAME: ${{ steps.git-metadata.outputs.REPO_NAME }}
|
||||||
|
TARGET_ENV: ${{ steps.git-metadata.outputs.TARGET_ENV }}
|
||||||
|
GIT_TAG: ${{ steps.git-metadata.outputs.GIT_TAG }}
|
||||||
|
GIT_SHA: ${{ steps.git-metadata.outputs.GIT_SHA }}
|
||||||
|
run: |
|
||||||
|
IMAGE_TAG=$TARGET_ENV-$($GIT_TAG != 'none' && echo $GIT_TAG || echo $GIT_SHA)
|
||||||
|
|
||||||
|
echo "IMAGE_NAME=molvaapp/${{ steps.git-metadata.outputs.REPO_NAME }}" >> $GITHUB_OUTPUT
|
||||||
|
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Build and Push Docker Image
|
||||||
|
needs: docker-metadata
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: ${{ steps.docker-metadata.outputs.IMAGE_NAME }}
|
||||||
|
IMAGE_TAG: ${{ steps.docker-metadata.outputs.IMAGE_TAG }}
|
||||||
|
CONFIG_FILE: .build/config/${{ steps.git-metadata.outputs.TARGET_ENV }}.yaml
|
||||||
|
run: |
|
||||||
|
docker build \
|
||||||
|
--build-arg BUILD_LDFLAGS="-w -s" \
|
||||||
|
--build-arg CONFIG_FILE_PATH=$CONFIG_FILE \
|
||||||
|
-t $IMAGE_NAME:$IMAGE_TAG \
|
||||||
|
-t $IMAGE_NAME:latest \
|
||||||
|
.
|
||||||
|
|
||||||
|
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_NAME:latest
|
||||||
|
|
||||||
|
docker push $IMAGE_NAME:$IMAGE_TAG
|
||||||
|
docker push $IMAGE_NAME:latest
|
||||||
|
|
||||||
|
echo "Pushed image $IMAGE_NAME:$IMAGE_TAG and :latest"
|
@@ -11,15 +11,6 @@ on:
|
|||||||
description: Version to deploy (default is new, to see other versions use the 'Get available versions' workflow)
|
description: Version to deploy (default is new, to see other versions use the 'Get available versions' workflow)
|
||||||
required: false
|
required: false
|
||||||
default: new
|
default: new
|
||||||
logLevel:
|
|
||||||
description: Log level
|
|
||||||
required: false
|
|
||||||
default: info
|
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- info
|
|
||||||
- debug
|
|
||||||
- warning
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy_to_staging:
|
deploy_to_staging:
|
||||||
@@ -81,28 +72,6 @@ jobs:
|
|||||||
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_OUTPUT
|
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_OUTPUT
|
||||||
echo "TAG_LAST_PUSHED=${PUSH_DATE}" >> $GITHUB_OUTPUT
|
echo "TAG_LAST_PUSHED=${PUSH_DATE}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Build and Push Docker Image
|
|
||||||
if: ${{ inputs.version == 'new' }}
|
|
||||||
needs: docker-metadata
|
|
||||||
env:
|
|
||||||
IMAGE_NAME: ${{ steps.docker-metadata.outputs.IMAGE_NAME }}
|
|
||||||
IMAGE_TAG: ${{ steps.docker-metadata.outputs.IMAGE_TAG }}
|
|
||||||
CONFIG_FILE: .build/config/staging.yaml
|
|
||||||
run: |
|
|
||||||
docker build \
|
|
||||||
--build-arg BUILD_LDFLAGS="-w -s" \
|
|
||||||
--build-arg CONFIG_FILE_PATH=$CONFIG_FILE \
|
|
||||||
-t $IMAGE_NAME:$IMAGE_TAG \
|
|
||||||
-t $IMAGE_NAME:latest \
|
|
||||||
.
|
|
||||||
|
|
||||||
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_NAME:latest
|
|
||||||
|
|
||||||
docker push $IMAGE_NAME:$IMAGE_TAG
|
|
||||||
docker push $IMAGE_NAME:latest
|
|
||||||
|
|
||||||
echo "Pushed image $IMAGE_NAME:$IMAGE_TAG and :latest"
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
id: install-dependencies
|
id: install-dependencies
|
||||||
run: |
|
run: |
|
||||||
|
Reference in New Issue
Block a user