Skip to content

Workflow file for this run

name: Splunk Add-on Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Checkout to repository
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Install dependencies
run: |
pip install pipenv
pipenv install --dev
- name: Unit Testing
run: |
pipenv run pytest -v
- name: Run Flake8
run: |
pipenv run flake8 ./add-on/TA-Demisto
- name: Compress Add-on
run: |
mkdir $GITHUB_WORKSPACE/artifacts
export SPL_PATH="$GITHUB_WORKSPACE/artifacts/demisto-add-on-for-splunk.tgz"
echo "SPL_PATH=$SPL_PATH" >> $GITHUB_ENV
cd add-on
COPYFILE_DISABLE=1 tar -cvzf $SPL_PATH --exclude='*.pyc' TA-Demisto
- name: Upload tar file to artifacts
uses: actions/upload-artifact@v2
with:
name: demisto-add-on-for-splunk.tgz
path: ${{ env.SPL_PATH }}
- name: Run AppInspect
env:
SPLUNK_USERNAME: ${{ secrets.SPLUNK_USERNAME }}
SPLUNK_PASSWORD: ${{ secrets.SPLUNK_PASSWORD }}
SPL_PATH: ${{ env.SPL_PATH }}
run: |
pipenv run python .github/appinspect.py $SPLUNK_USERNAME $SPLUNK_PASSWORD $SPL_PATH
- name: Create Splunk Container with Add-on
if: ${{ always() }}
env:
ADD_ON_DIR: add-on/TA-Demisto
run: |
docker run -it --mount type=bind,source=$GITHUB_WORKSPACE/"$ADD_ON_DIR",target=/opt/splunk/etc/apps/TA-Demisto/ -d -p "8000:8000" -p "8088:8088" -p "8089:8089" -e "SPLUNK_START_ARGS=--accept-license" -e "SPLUNK_PASSWORD=changeme" --name splunk splunk/splunk:latest
IS_CONTAINER_HEALTHY=false
TRY_COUNT=1
MAX_TRIES=10
while [ "$IS_CONTAINER_HEALTHY" = false ] && [[ $TRY_COUNT -le $MAX_TRIES ]]; do
echo "waiting for container to be ready..."
sleep 20
CONTAINER_STATUS=$(docker inspect --format='{{.State.Health.Status}}' splunk)
[ "$CONTAINER_STATUS" = "healthy" ] && IS_CONTAINER_HEALTHY=true || IS_CONTAINER_HEALTHY=false
done
echo "Container is ready!"
HOST=https://localhost:8089
echo "HOST=$HOST" >> $GITHUB_ENV
ADD_ON_PATH=$HOST/servicesNS/nobody/TA-Demisto
echo "ADD_ON_PATH=$ADD_ON_PATH" >> $GITHUB_ENV
- name: Setup Add-on
if: ${{ always() }}
env:
HOST: ${{ env.HOST }}
ADD_ON_PATH: ${{ env.ADD_ON_PATH }}
DEMISTO_URL: https://test.com
DEMISTO_API_KEY: test_api_key
run: |
echo "First-time password setting"
docker exec splunk sudo /opt/splunk/bin/splunk edit user admin -password passw0rd -role admin -auth admin:changeme
echo "Setting up Demisto client credentials"
# curl -k -u admin:passw0rd "$ADD_ON_PATH"/configs/conf-demistosetup/demistoenv/ -d VALIDATE_SSL=false -d DEMISTOURL="$DEMISTO_URL" -d AUTHKEY=$DEMISTO_API_KEY