Skip to content

Update the actions versions #62

Update the actions versions

Update the actions versions #62

Workflow file for this run

name: XSOAR CI/CD
on:
push:
jobs:
build:
runs-on: ubuntu-latest
env:
BRANCH_NAME: ${{ github.ref_name }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
DEMISTO_README_VALIDATION: false
steps:
- name: XSOAR CI/CD master checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Content checkout
uses: actions/checkout@v4
with:
repository: demisto/content
path: content
- name: Install poetry
uses: Gr1N/setup-poetry@v9
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.9.12
cache: poetry
- name: Install python dependencies
run: |
poetry install
- name: Prepare Environment
run: |
source $GITHUB_WORKSPACE/.venv/bin/activate
echo "PATH=/home/runner/.local/bin:$PATH" >> $GITHUB_ENV
echo "PYTHONPATH=${GITHUB_WORKSPACE}/content:${GITHUB_WORKSPACE}:${PYTHONPATH}" >> $GITHUB_ENV
echo "NEW_PACKS_FOLDER=${GITHUB_WORKSPACE}/content/new_packs_zips" >> $GITHUB_ENV
PACKS_CHANGED=$(python $GITHUB_WORKSPACE/build_related_scripts/get_modified_packs.py --repo_path $GITHUB_WORKSPACE/ --prev-ver ${DEFAULT_BRANCH})
echo "PACKS_CHANGED=${PACKS_CHANGED}" >> $GITHUB_ENV
- name: Prepare Venv
run: |
cd $GITHUB_WORKSPACE/content/
# Install node packages
npm install .
git config diff.renameLimit 6000
echo "========== Build Parameters =========="
python --version
demisto-sdk --version
echo "====================================="
- name: Run Pre-commit including Validate, Unit Testing and Linting
if: always()
run: |
source $GITHUB_WORKSPACE/content/.venv/bin/activate
cd $GITHUB_WORKSPACE
# Copy necessary files
cp $GITHUB_WORKSPACE/content/Tests/demistomock/demistomock.py ./
cp $GITHUB_WORKSPACE/content/Tests/demistomock/demistomock.ps1 ./
cp $GITHUB_WORKSPACE/content/Packs/Base/Scripts/CommonServerPython/CommonServerPython.py ./
cp $GITHUB_WORKSPACE/content/Packs/Base/Scripts/CommonServerPowerShell/CommonServerPowerShell.ps1 ./
mkdir -p ./dev_envs/pytest/
cp $GITHUB_WORKSPACE/content/Tests/scripts/dev_envs/pytest/conftest.py ./dev_envs/pytest/
# Run pre-commit on all changed files
# You can choose what pre-commit hooks to run in the .pre-commit-config_template.yaml file
# See https://docs-cortex.paloaltonetworks.com/r/1/Demisto-SDK-Guide/pre-commit for more information
# Note: The demisto-sdk validate command is included in the pre-commit hooks,
# and you can configure which checks to run in the validation_config.toml file.
# See https://xsoar.pan.dev/docs/concepts/demisto-sdk-validate for more information about the validate command
demisto-sdk pre-commit -g --prev-version ${DEFAULT_BRANCH}
- name: Create Packs Artifacts
run: |
if [ $PACKS_CHANGED ]; then
source $GITHUB_WORKSPACE/content/.venv/bin/activate
demisto-sdk prepare-content --input $PACKS_CHANGED --output $NEW_PACKS_FOLDER
else
echo "No packs has changed, skipping step."
fi
- name: Upload Packs to Artifacts Server
# In case 2 below (UPLOAD DIRECTLY TO YOUR XSOAR MACHINE) needed to add these secrets and variables
# For more information - https://docs-cortex.paloaltonetworks.com/r/1/Demisto-SDK-Guide/Environment-variables-setup
env:
DEMISTO_BASE_URL: ${{ secrets.DEMISTO_BASE_URL }}
DEMISTO_API_KEY: ${{ secrets.DEMISTO_API_KEY }}
# For Cortex XSOAR 8 and Cortex XSIAM add the following variable:
XSIAM_AUTH_ID: ${{ vars.XSIAM_AUTH_ID }}
run : |
if [ $PACKS_CHANGED ]; then
if [ $BRANCH_NAME == ${DEFAULT_BRANCH} ]; then
echo "Uploading artifacts ${PACKS_CHANGED}."
# Select the way you want to install the packs on the machine, and remove the second part
# For example: Choose the option 1 - UPLOAD TO ARTIFACTS SERVER OPTION, and remove the option 2 - UPLOAD DIRECTLY TO YOUR XSOAR MACHINE.
# For more information - https://xsoar.pan.dev/docs/reference/articles/xsoar-ci-cd#to-deploy-content
# 1. ========= UPLOAD TO ARTIFACTS SERVER OPTION =========
# Upload to the artifacts server of your choice.
# Create a file with the service account data
# use the bucket_upload script to upload your packs to google cloud storage
python $GITHUB_WORKSPACE/build_related_scripts/bucket_upload.py --service_account $GITHUB_WORKSPACE/service_account.json --packs_directory $NEW_PACKS_FOLDER --branch_name $BRANCH_NAME
# Delete the service account file
rm $GITHUB_WORKSPACE/service_account.json
# 2. ========= UPLOAD DIRECTLY TO YOUR XSOAR MACHINE (WHEN MERGING TO MAIN REPO) =========
cd $NEW_PACKS_FOLDER
for pack in *
do
demisto-sdk upload --input $pack
done
else
echo "The currrent branch is not the default branch, skipping upload to server."
fi
else
echo "No packs has changed, skipping step."
fi