mirror of
https://github.com/containers/podman.git
synced 2026-07-10 07:15:05 -04:00
Many GitHub Actions workflows currently trigger on user forks, leading to unnecessary CI resource consumption, unwanted bot behavior, and inevitable failures. This commit restricts these specific workflows to only run on the primary `containers/podman` repository. The restricted workflows fall into two main categories: 1. Require Custom Upstream Secrets: Workflows like `release`, `mac-pkg`, `cherry-pick`, and `dev-bump` rely on secrets (e.g., Apple/Azure certs, PODMANBOT_TOKEN, ACTION_MAIL_*) that are unavailable in forks. 2. Manage Upstream Tracker State: Workflows like `assign`, `stale`, and `labeler` are intended strictly for managing the primary project's issues and PRs. Running them on personal forks creates unwanted noise. Additionally, refactored several complex `if` conditions using YAML multi-line strings (`|`) to maintain and improve readability. Signed-off-by: Byounguk Lee <nimdrak@gmail.com>
45 lines
1.7 KiB
YAML
45 lines
1.7 KiB
YAML
name: Assign Command
|
|
|
|
on:
|
|
issue_comment:
|
|
types: [created]
|
|
|
|
jobs:
|
|
assign:
|
|
# Only run on issue comments (not PR comments)
|
|
if: |
|
|
!github.event.issue.pull_request &&
|
|
contains(github.event.comment.body, '/assign') &&
|
|
github.repository == 'podman-container-tools/podman'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
issues: write
|
|
steps:
|
|
- name: Self-assign if unassigned
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
REPO: ${{ github.repository }}
|
|
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
|
COMMENTER: ${{ github.event.comment.user.login }}
|
|
run: |
|
|
# Check if issue has any assignees
|
|
ASSIGNEES=$(gh issue view "$ISSUE_NUMBER" --repo "$REPO" --json assignees -q '.assignees | length')
|
|
|
|
if [ "$ASSIGNEES" -eq 0 ]; then
|
|
# Use API directly to assign (works for any GitHub user, not just collaborators)
|
|
if gh api "repos/${REPO}/issues/${ISSUE_NUMBER}/assignees" -X POST -f "assignees[]=${COMMENTER}" --silent; then
|
|
echo "Successfully assigned @${COMMENTER} to issue #${ISSUE_NUMBER}"
|
|
else
|
|
echo "Failed to assign @${COMMENTER} to issue #${ISSUE_NUMBER}"
|
|
exit 1
|
|
fi
|
|
else
|
|
# Add commenter as an additional assignee
|
|
if gh api "repos/${REPO}/issues/${ISSUE_NUMBER}/assignees" -X POST -f "assignees[]=${COMMENTER}" --silent; then
|
|
echo "Successfully added @${COMMENTER} as an additional assignee to issue #${ISSUE_NUMBER}"
|
|
else
|
|
echo "Failed to add @${COMMENTER} as an additional assignee to issue #${ISSUE_NUMBER}"
|
|
exit 1
|
|
fi
|
|
fi
|