This commit is contained in:
@@ -1,8 +1,25 @@
|
|||||||
name: Deploy Staging
|
name: Deploy Staging
|
||||||
|
|
||||||
on:
|
on:
|
||||||
repository_dispatch:
|
workflow_dispatch:
|
||||||
types: [deploy-request]
|
inputs:
|
||||||
|
environment:
|
||||||
|
description: Environment to deploy to
|
||||||
|
required: true
|
||||||
|
default: staging
|
||||||
|
version:
|
||||||
|
description: Version to deploy (default is new, to see other versions use the 'Get available versions' workflow)
|
||||||
|
required: false
|
||||||
|
default: new
|
||||||
|
logLevel:
|
||||||
|
description: Log level
|
||||||
|
required: false
|
||||||
|
default: info
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- info
|
||||||
|
- debug
|
||||||
|
- warning
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy_to_staging:
|
deploy_to_staging:
|
||||||
@@ -16,104 +33,99 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Debug inputs
|
- name: Extract Git metadata
|
||||||
|
id: git-metadata
|
||||||
run: |
|
run: |
|
||||||
echo "Environment: ${{ github.event.client_payload.environment }}"
|
echo "GIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||||
echo "Version: ${{ github.event.client_payload.version }}"
|
echo "GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo 'none')" >> $GITHUB_OUTPUT
|
||||||
echo "Available versions: ${{ github.event.client_payload.available_versions }}"
|
|
||||||
|
|
||||||
# - name: Extract Git metadata
|
- name: Login to Docker Registry
|
||||||
# id: git-metadata
|
run: |
|
||||||
# run: |
|
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
||||||
# 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
|
|
||||||
|
|
||||||
# - name: Login to Docker Registry
|
- name: Build and Push Docker Image
|
||||||
# run: |
|
if: ${{ inputs.version == 'new' }}
|
||||||
# echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
needs: git-metadata
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: molvaapp/test_deploy
|
||||||
|
CONFIG_FILE: .build/config/staging.yaml
|
||||||
|
run: |
|
||||||
|
IMAGE_TAG=${{ inputs.environment }}-${{ steps.git-metadata.outputs.GIT_TAG != 'none' && steps.git-metadata.outputs.GIT_TAG || steps.git-metadata.outputs.GIT_SHA }}
|
||||||
|
|
||||||
# - name: Build and Push Docker Image
|
docker build \
|
||||||
# needs: git-metadata
|
--build-arg BUILD_LDFLAGS="-w -s" \
|
||||||
# env:
|
--build-arg CONFIG_FILE_PATH=$CONFIG_FILE \
|
||||||
# IMAGE_NAME: molvaapp/test_deploy
|
-t $IMAGE_NAME:$IMAGE_TAG \
|
||||||
# CONFIG_FILE: .build/config/staging.yaml
|
-t $IMAGE_NAME:latest \
|
||||||
# run: |
|
.
|
||||||
# IMAGE_TAG=${{ inputs.environment }}-${{ steps.git-metadata.outputs.GIT_TAG != 'none' && steps.git-metadata.outputs.GIT_TAG || steps.git-metadata.outputs.GIT_SHA }}
|
|
||||||
|
|
||||||
# docker build \
|
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_NAME:latest
|
||||||
# --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
|
||||||
|
|
||||||
# docker push $IMAGE_NAME:$IMAGE_TAG
|
echo "Pushed image $IMAGE_NAME:$IMAGE_TAG and :latest"
|
||||||
# docker push $IMAGE_NAME:latest
|
|
||||||
|
|
||||||
# echo "Pushed image $IMAGE_NAME:$IMAGE_TAG and :latest"
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y gettext jq
|
||||||
|
|
||||||
# - name: Install dependencies
|
- name: Prepare environment
|
||||||
# run: |
|
run: |
|
||||||
# sudo apt-get update
|
mkdir -p /tmp/swarm-certs
|
||||||
# sudo apt-get install -y gettext jq
|
echo "${{ secrets.SWARM_CA_PEM }}" > /tmp/swarm-certs/ca.pem
|
||||||
|
echo "${{ secrets.SWARM_CERT_PEM }}" > /tmp/swarm-certs/cert.pem
|
||||||
|
echo "${{ secrets.SWARM_KEY_PEM }}" > /tmp/swarm-certs/key.pem
|
||||||
|
chmod 600 /tmp/swarm-certs/*.pem
|
||||||
|
|
||||||
# - name: Prepare environment
|
- name: Deploy to Swarm
|
||||||
# run: |
|
env:
|
||||||
# mkdir -p /tmp/swarm-certs
|
DOCKER_HOST: tcp://${{ secrets.SWARM_MANAGER_HOST }}:2376
|
||||||
# echo "${{ secrets.SWARM_CA_PEM }}" > /tmp/swarm-certs/ca.pem
|
DOCKER_TLS_VERIFY: 1
|
||||||
# echo "${{ secrets.SWARM_CERT_PEM }}" > /tmp/swarm-certs/cert.pem
|
DOCKER_CERT_PATH: /tmp/swarm-certs
|
||||||
# echo "${{ secrets.SWARM_KEY_PEM }}" > /tmp/swarm-certs/key.pem
|
|
||||||
# chmod 600 /tmp/swarm-certs/*.pem
|
|
||||||
|
|
||||||
# - name: Deploy to Swarm
|
VERSION: ${{ inputs.version }}
|
||||||
# env:
|
|
||||||
# DOCKER_HOST: tcp://${{ secrets.SWARM_MANAGER_HOST }}:2376
|
|
||||||
# DOCKER_TLS_VERIFY: 1
|
|
||||||
# DOCKER_CERT_PATH: /tmp/swarm-certs
|
|
||||||
|
|
||||||
# VERSION: ${{ inputs.version }}
|
KEYCLOAK_BASE_URL: ${{ secrets.KEYCLOAK_BASE_URL }}
|
||||||
|
KEYCLOAK_REALM: ${{ secrets.KEYCLOAK_REALM }}
|
||||||
|
KEYCLOAK_CLIENT_ID: ${{ secrets.KEYCLOAK_CLIENT_ID }}
|
||||||
|
KEYCLOAK_CLIENT_SECRET: ${{ secrets.KEYCLOAK_CLIENT_SECRET }}
|
||||||
|
|
||||||
# KEYCLOAK_BASE_URL: ${{ secrets.KEYCLOAK_BASE_URL }}
|
BROKER_HOST: ${{ secrets.BROKER_HOST }}
|
||||||
# KEYCLOAK_REALM: ${{ secrets.KEYCLOAK_REALM }}
|
BROKER_PORT: ${{ secrets.BROKER_PORT }}
|
||||||
# KEYCLOAK_CLIENT_ID: ${{ secrets.KEYCLOAK_CLIENT_ID }}
|
BROKER_USERNAME: ${{ secrets.BROKER_USERNAME }}
|
||||||
# KEYCLOAK_CLIENT_SECRET: ${{ secrets.KEYCLOAK_CLIENT_SECRET }}
|
BROKER_PASSWORD: ${{ secrets.BROKER_PASSWORD }}
|
||||||
|
|
||||||
# BROKER_HOST: ${{ secrets.BROKER_HOST }}
|
SHORTENER_SECRET_KEY: ${{ secrets.SHORTENER_SECRET_KEY }}
|
||||||
# BROKER_PORT: ${{ secrets.BROKER_PORT }}
|
|
||||||
# BROKER_USERNAME: ${{ secrets.BROKER_USERNAME }}
|
|
||||||
# BROKER_PASSWORD: ${{ secrets.BROKER_PASSWORD }}
|
|
||||||
|
|
||||||
# SHORTENER_SECRET_KEY: ${{ secrets.SHORTENER_SECRET_KEY }}
|
CACHE_ADDRS: ${{ secrets.CACHE_ADDRS }}
|
||||||
|
CACHE_PASSWORD: ${{ secrets.CACHE_PASSWORD }}
|
||||||
|
|
||||||
# CACHE_ADDRS: ${{ secrets.CACHE_ADDRS }}
|
DB_HOSTS: ${{ secrets.DB_HOSTS }}
|
||||||
# CACHE_PASSWORD: ${{ secrets.CACHE_PASSWORD }}
|
DB_PORT: ${{ secrets.DB_PORT }}
|
||||||
|
DB_USERNAME: ${{ secrets.DB_STG_USERNAME }}
|
||||||
|
DB_PASSWORD: ${{ secrets.DB_STG_PASSWORD }}
|
||||||
|
DB_DBNAME: ${{ secrets.DB_DBNAME }}
|
||||||
|
|
||||||
# DB_HOSTS: ${{ secrets.DB_HOSTS }}
|
INTEGRATION_VKUSVILL_API_TOKEN: ${{ secrets.INTEGRATION_VKUSVILL_API_TOKEN }}
|
||||||
# DB_PORT: ${{ secrets.DB_PORT }}
|
run: |
|
||||||
# DB_USERNAME: ${{ secrets.DB_STG_USERNAME }}
|
envsubst < docker-compose.staging.yaml > docker-compose.runtime.yaml
|
||||||
# DB_PASSWORD: ${{ secrets.DB_STG_PASSWORD }}
|
|
||||||
# DB_DBNAME: ${{ secrets.DB_DBNAME }}
|
|
||||||
|
|
||||||
# INTEGRATION_VKUSVILL_API_TOKEN: ${{ secrets.INTEGRATION_VKUSVILL_API_TOKEN }}
|
echo "Deploying version $VERSION to ${{ inputs.environment }}..."
|
||||||
# run: |
|
echo "Log level: ${{ inputs.logLevel }}"
|
||||||
# envsubst < docker-compose.staging.yaml > docker-compose.runtime.yaml
|
|
||||||
|
|
||||||
# echo "Deploying version $VERSION to ${{ inputs.environment }}..."
|
docker stack deploy \
|
||||||
# echo "Log level: ${{ inputs.logLevel }}"
|
--with-registry-auth \
|
||||||
|
-c docker-compose.runtime.yaml \
|
||||||
|
${{ env.STACK_NAME }}
|
||||||
|
|
||||||
# docker stack deploy \
|
- name: Cleanup
|
||||||
# --with-registry-auth \
|
run: |
|
||||||
# -c docker-compose.runtime.yaml \
|
rm -rf /tmp/swarm-certs
|
||||||
# ${{ env.STACK_NAME }}
|
rm -f docker-compose.runtime.yaml
|
||||||
|
|
||||||
# - name: Cleanup
|
- name: Post-deploy
|
||||||
# run: |
|
run: |
|
||||||
# rm -rf /tmp/swarm-certs
|
echo "Deployment to ${{ inputs.environment }} completed."
|
||||||
# rm -f docker-compose.runtime.yaml
|
echo "Version deployed: ${{ inputs.version }}"
|
||||||
|
|
||||||
# - name: Post-deploy
|
|
||||||
# run: |
|
|
||||||
# echo "Deployment to ${{ inputs.environment }} completed."
|
|
||||||
# echo "Version deployed: ${{ inputs.version }}"
|
|
||||||
|
@@ -1,53 +0,0 @@
|
|||||||
name: Trigger Deploy
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
environment:
|
|
||||||
description: Environment to deploy to
|
|
||||||
required: true
|
|
||||||
default: staging
|
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- staging
|
|
||||||
- production
|
|
||||||
logLevel:
|
|
||||||
description: Log level
|
|
||||||
required: false
|
|
||||||
default: info
|
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- info
|
|
||||||
- debug
|
|
||||||
- warning
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
get_versions_and_trigger:
|
|
||||||
name: Get available versions and trigger deploy
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
steps:
|
|
||||||
- name: Get available versions from Docker Registry
|
|
||||||
id: get_versions
|
|
||||||
env:
|
|
||||||
REGISTRY: hub.docker.com
|
|
||||||
REPO: ${{ github.repository }}
|
|
||||||
run: |
|
|
||||||
REPO_NAME=$(echo $REPO | cut -d'/' -f2)
|
|
||||||
|
|
||||||
TAGS=$(wget -q -O - "https://$REGISTRY/v2/namespaces/molvaapp/repositories/$REPO_NAME/tags?page_size=100" | jq -r '.results[].name' | tr '\n' ',')
|
|
||||||
|
|
||||||
echo "version_options=${TAGS%,}" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Trigger main deployment workflow
|
|
||||||
uses: peter-evans/repository-dispatch@v2
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.PAT_TOKEN }}
|
|
||||||
repository: AlexOreL/test_deploy
|
|
||||||
event-type: deploy-request
|
|
||||||
client-payload: |
|
|
||||||
{
|
|
||||||
"environment": "${{ github.event.inputs.environment }}",
|
|
||||||
"version": "latest",
|
|
||||||
"logLevel": "${{ github.event.inputs.logLevel }}",
|
|
||||||
"available_versions": "${{ steps.get_versions.outputs.version_options }}"
|
|
||||||
}
|
|
23
.gitea/workflows/get_versions.yaml
Normal file
23
.gitea/workflows/get_versions.yaml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
name: Get available versions
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
get_available_versions:
|
||||||
|
name: Get available versions
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
outputs:
|
||||||
|
version_options: ${{ steps.get_versions.outputs.version_options }}
|
||||||
|
steps:
|
||||||
|
- name: Get available versions from Docker Registry
|
||||||
|
id: get_versions
|
||||||
|
env:
|
||||||
|
REGISTRY: hub.docker.com
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
|
run: |
|
||||||
|
REPO_NAME=$(echo $REPO | cut -d'/' -f2)
|
||||||
|
|
||||||
|
TAGS=$(wget -q -O - "https://$REGISTRY/v2/namespaces/molvaapp/repositories/$REPO/tags?page_size=100" | jq -r '.results[].name')
|
||||||
|
|
||||||
|
echo "Available versions:\n$TAGS"
|
Reference in New Issue
Block a user