Skip to content

Use env rather than variables #1

Use env rather than variables

Use env rather than variables #1

Workflow file for this run

name: ES|QL Validation

Check failure on line 1 in .github/workflows/esql-validation.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/esql-validation.yml

Invalid workflow file

(Line: 15, Col: 13): Unrecognized named-value: 'secrets'. Located at position 2 within expression: !secrets.cloud_id && !secrets.api_key, (Line: 22, Col: 13): Unrecognized named-value: 'secrets'. Located at position 2 within expression: !secrets.cloud_id && !secrets.api_key, (Line: 43, Col: 13): Unrecognized named-value: 'secrets'. Located at position 2 within expression: !secrets.cloud_id && !secrets.api_key
on:
push:
branches: [ "main", "8.*", "9.*" ]
pull_request:
branches: [ "*" ]
paths:
- 'rules/**/*.toml'
jobs:
build-and-validate:
runs-on: ubuntu-latest
steps:
- name: Check out repository
if: ${{ !secrets.cloud_id && !secrets.api_key }}
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with:
path: elastic-container
repository: eric-forte-elastic/elastic-container
- name: Build and run containers
if: ${{ !secrets.cloud_id && !secrets.api_key }}
run: |
cd elastic-container
GENERATED_PASSWORD=$(openssl rand -base64 16)
sed -i 's/changeme/$GENERATED_PASSWORD/' .env
echo "GENERATED_PASSWORD=$GENERATED_PASSWORD" >> $GITHUB_ENV
set -x
bash elastic-container.sh start
- name: Setup Detection Rules
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with:
fetch-depth: 0
- name: Set up Python 3.13
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6
with:
python-version: '3.13'
- name: Get API Key and setup auth
if: ${{ !secrets.cloud_id && !secrets.api_key }}
env:
DR_ELASTICSEARCH_URL: "https://localhost:9200"
ES_USER: "elastic"
ES_PASSWORD: ${{ env.GENERATED_PASSWORD }}
run: |
cd detection-rules
response=$(curl -k -X POST -u "$ES_USER:$ES_PASSWORD" -H "Content-Type: application/json" -d '{
"name": "tmp-api-key",
"expiration": "1d"
}' "$DR_ELASTICSEARCH_URL/_security/api_key")
DR_API_KEY=$(echo "$response" | jq -r '.encoded')
echo "DR_API_KEY=$DR_API_KEY" >> $GITHUB_ENV
- name: Install dependencies
run: |
cd detection-rules
python -m pip install --upgrade pip
pip cache purge
pip install .[dev]
- name: Validate Test ESQL Rule
env:
DR_CLOUD_ID: ${{ secrets.cloud_id }}
DR_KIBANA_URL: ${{ secrets.cloud_id == '' && 'https://localhost:5601' || '' }}
DR_ES_USER: ${{ secrets.cloud_id == '' && 'elastic' || '' }}
DR_API_KEY: ${{ secrets.api_key || env.DR_API_KEY }}
run: |
cd detection-rules
python -m detection_rules dev test esql-remote-validation