Skip to content

ci: Create top-issues.yml #85

ci: Create top-issues.yml

ci: Create top-issues.yml #85

name: Filebeat Deployment CI
on:
push:
branches:
- main
- deploy-*
paths-ignore:
- configs/alertmanager/**
- configs/blackbox_exporter/**
- configs/grafana/**
- configs/kibana/**
- configs/prometheus/**
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
host:
# dockers
- "10.1.0.200"
# prod dockers
- "10.1.0.201"
# monitoring
- "10.1.0.203"
steps:
- name: Set env variables
run: |
# direct container access
# deploy target
echo "SSH_HOST=${{ matrix.host }}" >> $GITHUB_ENV
echo "SSH_PROXY_HOST=ovh1.openfoodfacts.org" >> $GITHUB_ENV
echo "SSH_USERNAME=off" >> $GITHUB_ENV
echo "MONITORING_HOST=10.1.0.203" >> $GITHUB_ENV
- name: Checkout git repository
uses: appleboy/ssh-action@master
with:
host: ${{ env.SSH_HOST }}
username: ${{ env.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
proxy_host: ${{ env.SSH_PROXY_HOST }}
proxy_username: ${{ env.SSH_USERNAME }}
proxy_key: ${{ secrets.SSH_PRIVATE_KEY }}
script_stop: false
script: |
# Clone Git repository if not already there
[ ! -d 'filebeat' ] && git clone --depth 1 https://github.com/${{ github.repository }} filebeat --no-single-branch 2>&1
# Go to repository directory
cd filebeat/
# Fetch newest commits (in case it wasn't freshly cloned)
git fetch --depth 1
# Checkout current commit SHA
git checkout -qf ${{ github.sha }}
# Change permission of filebeat config
# without using sudo !
docker run --rm -v $(pwd)/configs/filebeat:/mnt -w /mnt bash chown root:root config.yml
- name: Set environment variables
uses: appleboy/ssh-action@master
with:
host: ${{ env.SSH_HOST }}
username: ${{ env.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
proxy_host: ${{ env.SSH_PROXY_HOST }}
proxy_username: ${{ env.SSH_USERNAME }}
proxy_key: ${{ secrets.SSH_PRIVATE_KEY }}
script_stop: false
script: |
# Go to repository directory
cd filebeat/
# Set Docker Compose variables
echo "DOCKER_CLIENT_TIMEOUT=120" > .env
echo "COMPOSE_HTTP_TIMEOUT=120" >> .env
echo "COMPOSE_PROJECT_NAME=filebeat" >> .env
echo "COMPOSE_PATH_SEPARATOR=;" >> .env
echo "COMPOSE_FILE=docker-compose.node.yml" >> .env
# Kibana
echo "KIBANA_URI=${{ env.MONITORING_HOST }}:5601" >> .env
# Filebeat
echo "ELASTICSEARCH_HOSTS=http://${{ env.MONITORING_HOST }}:9200" >> .env
- name: Start services
uses: appleboy/ssh-action@master
with:
host: ${{ env.SSH_HOST }}
username: ${{ env.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
proxy_host: ${{ env.SSH_PROXY_HOST }}
proxy_username: ${{ env.SSH_USERNAME }}
proxy_key: ${{ secrets.SSH_PRIVATE_KEY }}
script_stop: false
script: |
cd filebeat/
make down && make up
- name: Check services are up
uses: appleboy/ssh-action@master
if: ${{ always() }}
with:
host: ${{ env.SSH_HOST }}
username: ${{ env.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
proxy_host: ${{ env.SSH_PROXY_HOST }}
proxy_username: ${{ env.SSH_USERNAME }}
proxy_key: ${{ secrets.SSH_PRIVATE_KEY }}
script_stop: false
script: |
cd filebeat/
make livecheck
- name: Cleanup obsolete Docker objects
uses: appleboy/ssh-action@master
if: ${{ always() }}
with:
host: ${{ env.SSH_HOST }}
username: ${{ env.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
proxy_host: ${{ env.SSH_PROXY_HOST }}
proxy_username: ${{ env.SSH_USERNAME }}
proxy_key: ${{ secrets.SSH_PRIVATE_KEY }}
script_stop: false
script: |
cd filebeat/
make prune