Add data #454
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: | |
- trunk | |
- feature/* | |
pull_request: | |
branches: | |
- trunk | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install virtualenv | |
sudo apt-get update | |
sudo apt-get install openssh-client -y | |
- name: Run Unit Test | |
run: | | |
cd tools/ | |
python -m virtualenv _venv | |
source _venv/bin/activate | |
python -m pip install --upgrade pip | |
python -m pip install -r requirements_test.txt | |
python -m pip install -r requirements.txt | |
python -m pytest -x --cov=devsecops_engine_tools --cov-config=.coveragerc | |
python -m coverage report -m | |
python -m coverage xml | |
- name: Run analysis on SonarQube | |
uses: SonarSource/sonarqube-scan-action@v2 | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
with: | |
projectBaseDir: tools | |
args: > | |
-Dsonar.organization=grupo-bancolombia | |
-Dsonar.projectKey=bancolombia_devsecops-engine-tools | |
-Dsonar.python.coverage.reportPaths=coverage.xml | |
-Dsonar.language=py | |
-Dsonar.verbose=true | |
-Dsonar.exclusions=**test_integrations_defect_dojo.py**,**/test/**,**/example/**,**setup.py**,**hello_world**,**Dockerfile**,**/coverage/** | |
-Dsonar.coverage.exclusions=**test_integrations_defect_dojo.py**,**/test/**,**/example/**,**setup.py**,**hello_world**,**Dockerfile/**,**/coverage/** | |
- name: Build | |
if: contains(github.ref,'refs/heads/trunk') || contains(github.event.head_commit.message, 'deploy dev') | |
run: | | |
cd tools/ | |
source _venv/bin/activate | |
python -m pip install setuptools virtualenv wheel | |
python setup.py sdist bdist_wheel | |
- name: Store the distribution packages | |
if: contains(github.ref,'refs/heads/trunk') || contains(github.event.head_commit.message, 'deploy dev') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: tools/dist/ | |
deploy_dev: | |
if: ${{ contains(github.event.head_commit.message, 'deploy dev') }} | |
runs-on: ubuntu-latest | |
needs: build | |
environment: release | |
permissions: | |
id-token: write | |
steps: | |
- name: Download the distribution packages | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: tools/dist/ | |
- name: Publish a Python distribution to PyPI Test | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: tools/dist/ | |
repository-url: https://test.pypi.org/legacy/ | |
deploy_prod: | |
if: ${{ contains(github.ref,'refs/heads/trunk') }} | |
runs-on: ubuntu-latest | |
needs: build | |
environment: release | |
permissions: | |
id-token: write | |
steps: | |
- name: Download the distribution packages | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: tools/dist/ | |
- name: Publish a Python distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: tools/dist/ | |
create_tag: | |
needs: | |
- deploy_prod | |
runs-on: ubuntu-latest | |
steps: | |
- name: Generate a token of Github APP | |
id: generate_token | |
uses: tibdex/github-app-token@v1 | |
with: | |
app_id: ${{ secrets.APP_ID_ADMIN_GITHUB }} | |
private_key: ${{ secrets.APP_PRIVATE_KEY_ADMIN_GITHUB }} | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.generate_token.outputs.token }} | |
- name: Create new tag ${{ github.event.inputs.release_number }} | |
run: | | |
VERSION=$(grep -E "version" tools/devsecops_engine_tools/version.py | cut -d= -f2 | sed "s/[[:space:]']//g") | |
NEW_TAG="v$VERSION" | |
echo "New Tag: $NEW_TAG" | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git tag -a $NEW_TAG -m "[bot] release $NEW_TAG" | |
- name: Push tag | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ steps.generate_token.outputs.token }} | |
tags: true |