Skip to content

Commit 7a47491

Browse files
authored
Migrate content bot automations (demisto#9043)
1 parent 8482b89 commit 7a47491

13 files changed

Lines changed: 577 additions & 87 deletions

File tree

.circleci/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ references:
290290
python3 -m pytest ./Tests/Marketplace/Tests/ -v
291291
python3 -m pytest ./Tests/scripts/utils/tests -v
292292
293+
# TODO: replace this line with running all unit tests in Utils directory
294+
# see issue https://github.com/demisto/etc/issues/29435
295+
python3 -m pytest ./Utils/github_workflow_scripts/ -v
296+
293297
if [ -n "${DEMISTO_SDK_NIGHTLY}" ] ; then
294298
./Tests/scripts/sdk_pylint_check.sh
295299
fi
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Create Internal PR from Merged External PR
2+
on:
3+
pull_request_target:
4+
types: [closed]
5+
branches:
6+
- contrib/**
7+
8+
jobs:
9+
create_internal_pr:
10+
runs-on: ubuntu-latest
11+
if: github.repository == 'demisto/content' && github.event.action == 'closed' && github.event.pull_request.merged == true && github.event.pull_request.head.repo.fork == true
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
with:
16+
ref: master
17+
- name: Setup Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: '3.8'
21+
22+
- name: Print Context
23+
run: |
24+
echo "$GITHUB_CONTEXT"
25+
env:
26+
GITHUB_CONTEXT: ${{ toJson(github) }}
27+
28+
- name: Install Python Dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install pipenv
32+
- name: Create Internal PR
33+
env:
34+
CONTENTBOT_GH_ADMIN_TOKEN: ${{ secrets.CONTENTBOT_GH_ADMIN_TOKEN }}
35+
EVENT_PAYLOAD: ${{ toJson(github.event) }}
36+
run: |
37+
echo "Creating an internal PR from original merged external PR ${{ github.event.pull_request.html_url }}"
38+
cd Utils/github_workflow_scripts
39+
pipenv install --dev
40+
pipenv run ./create_internal_pr.py
41+
echo "Finished Creating Internal PR"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Handle New External PRs
2+
on:
3+
pull_request_target:
4+
types: [opened]
5+
6+
jobs:
7+
handle_new_external_pr:
8+
runs-on: ubuntu-latest
9+
if: github.repository == 'demisto/content' && github.event.action == 'opened' && github.event.pull_request.head.repo.fork == true
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
with:
14+
ref: master
15+
- name: Setup Python
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: '3.8'
19+
20+
- name: Print Context
21+
run: |
22+
echo "$GITHUB_CONTEXT"
23+
env:
24+
GITHUB_CONTEXT: ${{ toJson(github) }}
25+
26+
- name: Install Python Dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install pipenv
30+
- name: Update External PR
31+
env:
32+
CONTENTBOT_GH_ADMIN_TOKEN: ${{ secrets.CONTENTBOT_GH_ADMIN_TOKEN }}
33+
EVENT_PAYLOAD: ${{ toJson(github.event) }}
34+
run: |
35+
echo "Updating External PR ${{ github.event.pull_request.html_url }}"
36+
cd Utils/github_workflow_scripts
37+
pipenv install --dev
38+
pipenv run ./handle_external_pr.py
39+
echo "Finished Handling External PR"

.github/workflows/sync-contribution-base-branch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
CONTENTBOT_GH_ADMIN_TOKEN: ${{ secrets.CONTENTBOT_GH_ADMIN_TOKEN }}
2525
run: |
2626
echo "Updating contribution base branches (contrib/*)"
27-
cd Utils/contribution_sync
27+
cd Utils/github_workflow_scripts
2828
pipenv install --dev
2929
pipenv run ./sync_contrib_base.py
3030
echo "Finished updating base branches"

Utils/contribution_sync/Pipfile.lock

Lines changed: 0 additions & 85 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ url = "https://pypi.org/simple"
44
verify_ssl = true
55

66
[dev-packages]
7+
flake8 = "*"
78

89
[packages]
910
pygithub = "*"
1011
requests = "*"
12+
blessings = "*"
1113

1214
[requires]
1315
python_version = "3.8"

Utils/github_workflow_scripts/Pipfile.lock

Lines changed: 137 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)