Dependabot build and auto-review #142
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: Dependabot build and auto-review | ||
on: | ||
workflow_run: | ||
workflows: | ||
- 'Dependabot Build Transfer' | ||
branches-ignore: | ||
- 'dependabot/submodules/**' | ||
types: | ||
- completed | ||
permissions: | ||
pull-requests: write | ||
contents: write | ||
jobs: | ||
dependabot-build: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.actor == 'dependabot[bot]' }} | ||
strategy: | ||
max-parallel: 4 | ||
matrix: | ||
python-version: [3.6, 3.7, 3.8, 3.9] | ||
fail-fast: true | ||
steps: | ||
- name: Checkout gsfpy repo | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.workflow_run.head_branch }} | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip poetry | ||
- name: Free disk space on build worker | ||
run: | | ||
df -h | ||
sudo apt-get clean | ||
sudo apt-get autoclean && sudo apt-get autoremove -y | ||
df -h | ||
- name: Run tests | ||
env: | ||
run: | | ||
poetry install | ||
make test-all | ||
- name: Auto-reject Failed Dependabot PR | ||
if: ${{ failure() }} | ||
run: gh pr review --request-changes -b "Breaking change in dependent package version detected by Dependabot. Manual resolution required." ${{ github.event.workflow_run.head_branch }} | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
dependabot-merge: | ||
runs-on: ubuntu-latest | ||
needs: [dependabot-build] | ||
steps: | ||
- name: Checkout gsfpy repo | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.workflow_run.head_branch }} | ||
- name: Auto-approve Successful Dependabot PR | ||
run: gh pr review --approve ${{ github.event.workflow_run.head_branch }} | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
- name: Auto-merge Successful Dependabot PR | ||
if: ${{ success() }} | ||
run: gh pr merge --auto --squash ${{ github.event.workflow_run.head_branch }} | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |