57
Some checks failed
Deploy Production / Deploy to Staging (push) Has been skipped
Go Linter / Run golangci-lint (api_gateway) (push) Failing after 4m59s
Go Linter / Build golang services (api_gateway) (push) Has been skipped
Go Linter / Push Docker Images (api_gateway) (push) Has been skipped

This commit is contained in:
Alex Shevchuk
2025-08-20 23:42:28 +03:00
parent bde8a20a16
commit 94c1bb727b
4 changed files with 131 additions and 67 deletions

View File

@@ -11,61 +11,61 @@ on:
- release
jobs:
# lint:
# name: Run golangci-lint
# runs-on: ubuntu-22.04
lint:
name: Run golangci-lint
runs-on: ubuntu-22.04
# strategy:
# matrix:
# project:
# - api_gateway
strategy:
matrix:
project:
- api_gateway
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
steps:
- name: Checkout repository
uses: actions/checkout@v3
# - name: Set up Go
# uses: actions/setup-go@v4
# with:
# go-version: 1.23
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.23
# - name: Install golangci-lint
# run: |
# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.2
- name: Install golangci-lint
run: |
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
# run: |
# go mod tidy
# golangci-lint run -c ./.golangci-lint.yaml --fix=false --color=always
- name: Run golangci-lint
run: |
go mod tidy
golangci-lint run -c ./.golangci-lint.yaml --fix=false --color=always
# build:
# name: Build golang services
# runs-on: ubuntu-22.04
# needs: lint
build:
name: Build golang services
runs-on: ubuntu-22.04
needs: lint
# strategy:
# matrix:
# project:
# - api_gateway
strategy:
matrix:
project:
- api_gateway
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
steps:
- name: Checkout repository
uses: actions/checkout@v3
# - name: Set up Go
# uses: actions/setup-go@v4
# with:
# go-version: 1.23
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.23
# - name: Build golang services
# run: |
# go mod tidy
# CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o main cmd/main.go
- name: Build golang services
run: |
go mod tidy
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o main cmd/main.go
push:
name: Push Docker Images
runs-on: ubuntu-22.04
# needs: lint
needs: lint
if: ${{ gitea.ref == 'refs/heads/master' || gitea.ref == 'refs/heads/release' }}
strategy:

View File

@@ -7,14 +7,18 @@ on:
description: Environment to deploy to
required: true
default: staging
type: choice
options:
- staging
- production
version:
description: Version to deploy (default is new, to see other versions use the 'Get available versions' workflow)
description: Version to deploy (default is latest, to see other versions use the 'Get available versions' workflow)
required: false
default: new
default: latest
jobs:
deploy_to_staging:
name: Deploy to Staging
deploy:
name: Deploy to ${{ inputs.environment }}
runs-on: ubuntu-22.04
env:
@@ -29,15 +33,8 @@ jobs:
env:
REPO: ${{ github.repository }}
run: |
VERSION=${{ inputs.version }}
if [ ${VERSION} == "new" ]; then
GIT_SHA=$(git rev-parse --short HEAD)
GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo 'none')
else
GIT_SHA=$(echo ${VERSION} | cut -d'-' -f2)
GIT_TAG='none'
fi
GIT_SHA=$(git rev-parse --short HEAD)
GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo 'none')
echo "GIT_SHA=${GIT_SHA}" >> $GITHUB_OUTPUT
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT
@@ -58,15 +55,8 @@ jobs:
REGISTRY: hub.docker.com
REPO_NAME: ${{ steps.git-metadata.outputs.REPO_NAME }}
run: |
TARGET_TAG=${{ inputs.version }}
if [ ${TARGET_TAG} == "new" ]; then
PUSH_DATE=$(date +"%Y-%m-%d %T %Z")
IMAGE_TAG=${{ inputs.environment }}-${{ steps.git-metadata.outputs.GIT_TAG != 'none' && steps.git-metadata.outputs.GIT_TAG || steps.git-metadata.outputs.GIT_SHA }}
else
PUSH_DATE=$(wget -q -O - "https://$REGISTRY/v2/namespaces/molvaapp/repositories/$REPO_NAME/tags/${TARGET_TAG}/" | jq -r '.tag_last_pushed')
IMAGE_TAG=${{ inputs.version }}
fi
IMAGE_TAG=${{ inputs.version }}
PUSH_DATE=$(wget -q -O - "https://$REGISTRY/v2/namespaces/molvaapp/repositories/$REPO_NAME/tags/${IMAGE_TAG}/" | jq -r '.tag_last_pushed')
echo "IMAGE_NAME=molvaapp/${{ steps.git-metadata.outputs.REPO_NAME }}" >> $GITHUB_OUTPUT
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_OUTPUT
@@ -98,7 +88,7 @@ jobs:
DOCKER_TLS_VERIFY: 1
DOCKER_CERT_PATH: /tmp/swarm-certs
VERSION: ${{ inputs.version == 'new' && 'latest' || inputs.version }}
VERSION: ${{ inputs.version }}
APP_VERSION: ${{ inputs.environment }}-${{ steps.git-metadata.outputs.APP_COMMIT }}
APP_COMMIT: ${{ steps.git-metadata.outputs.APP_COMMIT }}
@@ -121,13 +111,13 @@ jobs:
DB_HOSTS: ${{ secrets.DB_HOSTS }}
DB_PORT: ${{ secrets.DB_PORT }}
DB_USERNAME: ${{ secrets.DB_STG_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_STG_PASSWORD }}
DB_USERNAME: ${{ inputs.environment == 'staging' && secrets.DB_STG_USERNAME || secrets.DB_PROD_USERNAME }}
DB_PASSWORD: ${{ inputs.environment == 'staging' && secrets.DB_STG_PASSWORD || secrets.DB_PROD_PASSWORD }}
DB_DBNAME: ${{ secrets.DB_DBNAME }}
INTEGRATION_VKUSVILL_API_TOKEN: ${{ secrets.INTEGRATION_VKUSVILL_API_TOKEN }}
run: |
envsubst < docker-compose.staging.yaml > docker-compose.runtime.yaml
envsubst < docker-compose.$VERSION.yaml > docker-compose.runtime.yaml
echo "Deploying version $VERSION to ${{ inputs.environment }}..."
echo "Log level: ${{ inputs.logLevel }}"