Test issue #59
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
--- | |
# Copyright (C) 2023 Maxwell G <maxwell@gtmx.me> | |
# SPDX-License-Identifier: GPL-3.0-or-later | |
"on": | |
pull_request_target: | |
issues: | |
types: | |
- opened | |
issue_comment: | |
types: | |
- created | |
workflow_dispatch: | |
inputs: | |
type: | |
required: true | |
type: choice | |
options: | |
- issue | |
- pr | |
number: | |
required: true | |
type: number | |
name: "Triage Issues and PRs" | |
jobs: | |
label_prs: | |
runs-on: ubuntu-latest | |
environment: github-bot | |
name: "Label Issue/PR" | |
steps: | |
- name: Print event information | |
env: | |
event_json: "${{ toJSON(github.event) }}" | |
run: | | |
echo "${event_json}" | |
# Use https://stackoverflow.com/a/75809743 to exit job | |
# instead of provisioning separate jobs with 'if' to save time. | |
# We want the triage job to run quickly. | |
- name: Check for comment command | |
if: "github.event.name == 'issue_comment' && github.event.comment.body != ''" | |
env: | |
COMMENT_BODY: "${{ github.event.comment.body }}" | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
if ! [[ "${COMMENT_BODY}" =~ ^/docbot ]]; then | |
echo "The comment is not a command: ${COMMENT_BODY}" | |
gh run cancel ${{ github.run_id }} | |
gh run watch ${{ github.run_id }} | |
fi | |
shell: bash | |
# - name: Generate temp GITHUB_TOKEN | |
# id: create_token | |
# uses: tibdex/github-app-token@v2 | |
# with: | |
# app_id: ${{ secrets.BOT_APP_ID }} | |
# private_key: ${{ secrets.BOT_APP_KEY }} | |
- name: Checkout parent repository | |
uses: actions/checkout@v4 | |
- name: Install Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Set up UV | |
run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
- name: Setup venv | |
run: | | |
uv venv venv | |
uv pip install --python venv \ | |
-e hacking/pr_labeler -c tests/pr_labeler.txt | |
- name: "Run the issue labeler" | |
if: "github.event.issue || inputs.type == 'issue'" | |
env: | |
event_json: "${{ toJSON(github.event) }}" | |
# GITHUB_TOKEN: ${{ steps.create_token.outputs.token }} | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
number: "${{ github.event.issue.number || inputs.number }}" | |
run: | | |
./venv/bin/ad-triage --owner gotmax23 issue "${number}" | |
- name: "Run the PR labeler" | |
if: "github.event.pull_request || inputs.type == 'pr'" | |
env: | |
event_json: "${{ toJSON(github.event) }}" | |
# GITHUB_TOKEN: ${{ steps.create_token.outputs.token }} | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
number: "${{ github.event.number || inputs.number }}" | |
run: | | |
./venv/bin/ad-triage --owner gotmax23 pr "${number}" |