54 это Санкт Петербург
All checks were successful
Deploy Production / Deploy to Staging (push) Has been skipped
All checks were successful
Deploy Production / Deploy to Staging (push) Has been skipped
This commit is contained in:
@@ -38,39 +38,60 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "GIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
echo "GIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||||
echo "GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo 'none')" >> $GITHUB_OUTPUT
|
echo "GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo 'none')" >> $GITHUB_OUTPUT
|
||||||
|
echo "REPO_OWNER=$(echo $REPO | cut -d'/' -f1)" >> $GITHUB_OUTPUT
|
||||||
|
echo "REPO_NAME=$(echo $REPO | cut -d'/' -f2)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Login to Docker Registry
|
- 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 }}
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
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
|
||||||
|
|
||||||
|
echo "IMAGE_NAME=molvaapp/${{ steps.git-metadata.outputs.REPO_NAME }}" >> $GITHUB_OUTPUT
|
||||||
|
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_OUTPUT
|
||||||
|
echo "TAG_LAST_PUSHED=${PUSH_DATE}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Setup Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Build and Push Docker Image
|
- name: Build and Push Docker Image
|
||||||
if: ${{ inputs.version == 'new' }}
|
if: ${{ inputs.version == 'new' }}
|
||||||
needs: git-metadata
|
needs: docker-metadata
|
||||||
env:
|
uses: docker/build-push-action@v5
|
||||||
IMAGE_NAME: molvaapp/test_deploy
|
with:
|
||||||
IMAGE_TAG: ${{ inputs.environment }}-${{ steps.git-metadata.outputs.GIT_TAG != 'none' && steps.git-metadata.outputs.GIT_TAG || steps.git-metadata.outputs.GIT_SHA }}
|
context: .
|
||||||
CONFIG_FILE: .build/config/staging.yaml
|
file: Dockerfile
|
||||||
run: |
|
push: true
|
||||||
docker build \
|
tags: ${{ steps.docker-metadata.outputs.IMAGE_NAME }}:${{ steps.docker-metadata.outputs.IMAGE_TAG }}
|
||||||
--build-arg BUILD_LDFLAGS="-w -s" \
|
build-args: |
|
||||||
--build-arg CONFIG_FILE_PATH=$CONFIG_FILE \
|
BUILD_LDFLAGS="-w -s"
|
||||||
-t $IMAGE_NAME:$IMAGE_TAG \
|
CONFIG_FILE_PATH=".build/config/staging.yaml"
|
||||||
-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
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y gettext jq
|
sudo apt-get install -y gettext jq
|
||||||
|
|
||||||
- name: Prepare environment
|
- name: Prepare environment
|
||||||
|
id: prepare-env
|
||||||
run: |
|
run: |
|
||||||
mkdir -p /tmp/swarm-certs
|
mkdir -p /tmp/swarm-certs
|
||||||
echo "${{ secrets.SWARM_CA_PEM }}" > /tmp/swarm-certs/ca.pem
|
echo "${{ secrets.SWARM_CA_PEM }}" > /tmp/swarm-certs/ca.pem
|
||||||
@@ -79,10 +100,12 @@ jobs:
|
|||||||
chmod 600 /tmp/swarm-certs/*.pem
|
chmod 600 /tmp/swarm-certs/*.pem
|
||||||
|
|
||||||
- name: Deploy to Swarm
|
- name: Deploy to Swarm
|
||||||
|
needs:
|
||||||
|
- git-metadata
|
||||||
|
- docker-metadata
|
||||||
|
- install-dependencies
|
||||||
|
- prepare-env
|
||||||
env:
|
env:
|
||||||
REGISTRY: hub.docker.com
|
|
||||||
REPO: ${{ github.repository }}
|
|
||||||
|
|
||||||
DOCKER_HOST: tcp://${{ secrets.SWARM_MANAGER_HOST }}:2376
|
DOCKER_HOST: tcp://${{ secrets.SWARM_MANAGER_HOST }}:2376
|
||||||
DOCKER_TLS_VERIFY: 1
|
DOCKER_TLS_VERIFY: 1
|
||||||
DOCKER_CERT_PATH: /tmp/swarm-certs
|
DOCKER_CERT_PATH: /tmp/swarm-certs
|
||||||
@@ -90,6 +113,7 @@ jobs:
|
|||||||
VERSION: ${{ inputs.version == 'new' && 'latest' || inputs.version }}
|
VERSION: ${{ inputs.version == 'new' && 'latest' || inputs.version }}
|
||||||
|
|
||||||
APP_COMMIT: ${{ steps.git-metadata.outputs.GIT_TAG != 'none' && steps.git-metadata.outputs.GIT_TAG || steps.git-metadata.outputs.GIT_SHA }}
|
APP_COMMIT: ${{ steps.git-metadata.outputs.GIT_TAG != 'none' && steps.git-metadata.outputs.GIT_TAG || steps.git-metadata.outputs.GIT_SHA }}
|
||||||
|
APP_BUILD_DATE: ${{ steps.docker-metadata.outputs.TAG_LAST_PUSHED }}
|
||||||
|
|
||||||
KEYCLOAK_BASE_URL: ${{ secrets.KEYCLOAK_BASE_URL }}
|
KEYCLOAK_BASE_URL: ${{ secrets.KEYCLOAK_BASE_URL }}
|
||||||
KEYCLOAK_REALM: ${{ secrets.KEYCLOAK_REALM }}
|
KEYCLOAK_REALM: ${{ secrets.KEYCLOAK_REALM }}
|
||||||
@@ -114,11 +138,6 @@ jobs:
|
|||||||
|
|
||||||
INTEGRATION_VKUSVILL_API_TOKEN: ${{ secrets.INTEGRATION_VKUSVILL_API_TOKEN }}
|
INTEGRATION_VKUSVILL_API_TOKEN: ${{ secrets.INTEGRATION_VKUSVILL_API_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
REPO_NAME=$(echo $REPO | cut -d'/' -f2)
|
|
||||||
|
|
||||||
APP_BUILD_DATE=$(wget -q -O - "https://$REGISTRY/v2/namespaces/molvaapp/repositories/$REPO_NAME/tags?page_size=100" \
|
|
||||||
| jq -r '.results[] | select(.name == "'$VERSION'") | .tag_last_pushed')
|
|
||||||
|
|
||||||
envsubst < docker-compose.staging.yaml > docker-compose.runtime.yaml
|
envsubst < docker-compose.staging.yaml > docker-compose.runtime.yaml
|
||||||
|
|
||||||
cat docker-compose.runtime.yaml
|
cat docker-compose.runtime.yaml
|
||||||
|
Reference in New Issue
Block a user