Skip to content

Commit

Permalink
Add workflow_call support to action and add action for repo reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
JamyGolden committed Aug 21, 2024
1 parent 838fe21 commit 4b709fa
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 35 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @tinted-theming/admins
38 changes: 3 additions & 35 deletions .github/workflows/auto-assign-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,6 @@ on:

jobs:
auto-assign:
runs-on: "ubuntu-latest"
permissions:
issues: "write"
outputs:
codeowners: ${{ steps.codeowners.outputs.value }}
steps:
- uses: actions/checkout@v4
- name: "Get teams from CODEOWNERS file"
id: "codeowners"
run: |
result=""
first_item=true
while IFS= read -r line; do
if [ "$first_item" = true ]; then
result="${line#* @tinted-theming/}"
first_item=false
else
result="$result, ${line#* @tinted-theming/}"
fi
done < .github/CODEOWNERS
if [ -z "$result" ]; then
echo "Error: unable to determine teams from .github/CODEOWNERS file"
exit 1
fi
echo "value=$result" >> $GITHUB_OUTPUT
- name: "Auto-assign issue"
uses: "pozil/auto-assign-issue@v2"
with:
repo-token: "${{ secrets.BOT_ACCESS_TOKEN }}"
teams: "${{ steps.codeowners.outputs.value }}"
numOfAssignee: 3
uses: ./.github/workflows/shared-auto-assign-issues.yml
secrets:
token: ${{ secrets.BOT_ACCESS_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/shared-auto-assign-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Auto assignment for issues"

on:
workflow_call:
secrets:
token:
description: "GitHub Access Token"
required: true

jobs:
auto-assign:
runs-on: "ubuntu-latest"
permissions:
issues: "write"
outputs:
codeowners: ${{ steps.codeowners.outputs.value }}
steps:
- name: "Check token value"
run: |
token="${{ secrets.token }}"
if [ -z "$token" ]; then
echo "'secrets.token' not provided."
exit 1
fi
- uses: actions/checkout@v4
- name: "Get teams from CODEOWNERS file"
id: "codeowners"
run: |
result=""
first_item=true
while IFS= read -r line; do
if [ "$first_item" = true ]; then
result="${line#* @tinted-theming/}"
first_item=false
else
result="$result, ${line#* @tinted-theming/}"
fi
done < .github/CODEOWNERS
if [ -z "$result" ]; then
echo "Error: unable to determine teams from .github/CODEOWNERS file"
exit 1
fi
echo "value=$result" >> $GITHUB_OUTPUT
- name: "Auto-assign issue"
uses: "pozil/auto-assign-issue@v2"
with:
repo-token: "${{ secrets.token }}"
teams: "${{ steps.codeowners.outputs.value }}"
numOfAssignee: 3

0 comments on commit 4b709fa

Please sign in to comment.