[User Story] User Create Account #13
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: Label User-Story with Epic | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
process_issue: | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} | |
steps: | |
- name: Verify Issue Type | |
id: type_check | |
run: | | |
issue_body="${{ github.event.issue.body }}" | |
echo "Issue body: $issue_body" | |
if [[ $issue_body == *"Epic Label"* ]]; then | |
echo "Issue is a User Story, proceeding with the workflow..." | |
else | |
echo "Issue is not a User Story. Skipping workflow..." | |
exit 78 # Exit with a neutral status code to indicate a skipped run | |
fi | |
- name: Install gh | |
run: | | |
sudo apt-get install gh # For Ubuntu-based runners | |
- uses: actions/checkout@v3 | |
- name: Apply epic label | |
run: | | |
epic_label=$(echo "${{ github.event.issue.body }}" | awk -v RS='###' '/Epic Label/ {gsub(/^[[:space:]]*Epic Label[[:space:]]*/, "epic:", $0); gsub(/^[[:space:]]+|[[:space:]]+$/, "", $0); print $0}'"") | |
echo "Applying Epic Label: $epic_label" | |
label_search_output=$(gh label list --json name -q ".[] | .name" | grep "$epic_label" || true) | |
if [ "$label_search_output" = "$epic_label" ]; then | |
echo "Label already exists, so skipping creation..."; | |
else | |
echo "Creating label $epic_label"; | |
gh label create "$epic_label" --description "New Epic $epic_label" --color E99695 | |
fi | |
gh issue edit ${{ github.event.issue.number }} --add-label "$epic_label" | |