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