Skip to content

CD Develop Environment #61

CD Develop Environment

CD Develop Environment #61

Workflow file for this run

name: "CD Develop Environment"
env:
DOCKER_VERSION: ${{ github.sha }}
on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches:
- 'dev'
workflow_dispatch:
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
configs: ${{ steps.read-artifact.outputs.configs || github.event_name == 'workflow_dispatch' }}
node_registry: ${{ steps.read-artifact.outputs.node-registry || github.event_name == 'workflow_dispatch' }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Download Artifact
if: ${{ github.event_name != 'workflow_dispatch' }}
uses: actions/download-artifact@v4
with:
name: project-changes
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- name: Read Outputs from JSON
if: ${{ github.event_name != 'workflow_dispatch' }}
id: read-artifact
run: |
content=$(cat outputs.json)
{
echo "configs=$(echo $content | jq -r '.configs')"
echo "node_registry=$(echo $content | jq -r '."node-registry"')"
} >> "$GITHUB_OUTPUT"
build-relayer:
needs: detect-changes
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: dev
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.DOCKER_REGISTRY_HOST }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build & Push Relayer Image
run: make build_relayer push_relayer -f Makefile.docker VERSION=${{ env.DOCKER_VERSION }} ENVIRONMENT=-dev
build-resolver:
needs: detect-changes
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: dev
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.DOCKER_REGISTRY_HOST }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build & Push Resolver Image
run: make build_resolver push_resolver -f Makefile.docker VERSION=${{ env.DOCKER_VERSION }} ENVIRONMENT=-dev
configs-deploy:
if: ${{ needs.detect-changes.outputs.configs == 'true' }}
needs: detect-changes
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: dev
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Ansible
run: |
python -m pip install --upgrade pip
pip install ansible
- name: Decrypt configs
run: |
echo "${{ secrets.VAULT_PASSWORD }}" > /tmp/vault_pass
ansible-vault decrypt assets/*.yaml --vault-password-file=/tmp/vault_pass
- name: Set permissions for config files
run: chmod -R 644 assets/*.yaml
- name: Deploy Configs
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST_DEV }}
username: ${{ secrets.SSH_USER_DEV }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
source: "assets/*.yaml"
target: ${{ secrets.PROJECT_CONFIG_PATH_DEV }}
strip_components: 1
debug: true
- name: Cleanup Vault Password File
if: always()
run: |
rm -f /tmp/vault_pass
node-registry-deploy:
if: ${{ needs.detect-changes.outputs.node_registry == 'true' }}
needs: detect-changes
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: dev
- name: Deploy Node Registry
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST_DEV }}
username: ${{ secrets.SSH_USER_DEV }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
source: "contracts/NodeRegistry.sol"
target: ${{ secrets.PROJECT_CONTRACT_PATH_DEV }}
strip_components: 1
deploy-services:
if: ${{ always() }}
needs:
- build-relayer
- build-resolver
- configs-deploy
- node-registry-deploy
runs-on: ubuntu-latest
steps:
- name: Deploy Images to DEV Environment
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST_DEV }}
port: 22
username: ${{ secrets.SSH_USER_DEV }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd ${{ secrets.PROJECT_PATH_DEV }}
./deploy.sh