Skip to content

🗃️ [New Component]: MQT QECC #5

🗃️ [New Component]: MQT QECC

🗃️ [New Component]: MQT QECC #5

Workflow file for this run

# .github/workflows/issue-to-pr.yml
name: '🤖 Auto-Generate Component PR from Issue'
on:
issues:
types: [opened]
permissions:
contents: write
pull-requests: write
jobs:
create_pr_from_issue:
# This job will only run if the new issue has the 'autogen-pr' label
if: contains(github.event.issue.labels.*.name, 'autogen-pr')
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: 'Parse Issue Body'
uses: stefanbuck/github-issue-parser@v3
id: issue-parser
with:
template-path: .github/ISSUE_TEMPLATE/new-component-request.yml # optional but recommended
- name: 'Create Branch, Commit, and Push'
run: |
NAME="${{ steps.issue-parser.outputs.issueparser_name }}"
MAINTAINERS="${{ steps.issue-parser.outputs.issueparser_maintainers }}"
DOCS="${{ steps.issue-parser.outputs.issueparser_docs }}"
GITHUB_REPO="${{ steps.issue-parser.outputs.issueparser_github }}"
DESCRIPTION="${{ steps.issue-parser.outputs.issueparser_description }}"
LANGUAGES="${{ steps.issue-parser.outputs.issueparser_languages }}"
FRAMEWORKS="${{ steps.issue-parser.outputs.issueparser_frameworks }}"
ISSUE_NUMBER="${{ github.event.issue.number }}"
SANITIZED_NAME=$(echo "$NAME" | tr '[:upper:]' '[:lower:]' | sed -e 's/[ \/]\+/-/g' -e 's/[^a-z0-9-]\+//g')
BRANCH_NAME="new/component-${ISSUE_NUMBER}-${SANITIZED_NAME}"
LANG_ARRAY=$(echo "$LANGUAGES" | sed 's/[^,]\+/\"&\"/g' | sed 's/, /", "/g' | sed 's/.*/[&]/')
FW_ARRAY=$(echo "$FRAMEWORKS" | sed 's/[^,]\+/\"&\"/g' | sed 's/, /", "/g' | sed 's/.*/[&]/')
MAINT_ARRAY=$(echo "$MAINTAINERS" | sed 's/[^,]\+/\"&\"/g' | sed 's/, /", "/g' | sed 's/.*/[&]/')
AUTHOR_NAME="${{ github.event.issue.user.login }}"
AUTHOR_EMAIL="${{ github.event.issue.user.id }}+${{ github.event.issue.user.login }}@users.noreply.github.com"
# Configure Git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Create branch, add file, commit, and push
git checkout -b $BRANCH_NAME
echo -e "---" > "_components/${SANITIZED_NAME}.md"
echo -e "title: \"${NAME}\"" >> "_components/${SANITIZED_NAME}.md"
echo -e "languages: $LANG_ARRAY" >> "_components/${SANITIZED_NAME}.md"
echo -e "frameworks: $FW_ARRAY" >> "_components/${SANITIZED_NAME}.md"
if [ -n "$DOCS" ] || [ -n "$GITHUB_REPO" ]; then
echo -e "links:" >> "_components/${SANITIZED_NAME}.md"
if [ -n "$DOCS" ]; then
echo -e " docs: \"${DOCS}\"" >> "_components/${SANITIZED_NAME}.md"
fi
if [ -n "$GITHUB_REPO" ]; then
echo -e " github: \"${GITHUB_REPO}\"" >> "_components/${SANITIZED_NAME}.md"
fi
fi
echo -e "maintainers: $MAINT_ARRAY" >> "_components/${SANITIZED_NAME}.md"
echo -e "---" >> "_components/${SANITIZED_NAME}.md"
echo -e "" >> "_components/${SANITIZED_NAME}.md"
echo -e "${DESCRIPTION}" >> "_components/${SANITIZED_NAME}.md"
git add "_components/${SANITIZED_NAME}.md"
git -c "author.name=${AUTHOR_NAME}" -c "author.email=${AUTHOR_EMAIL}" \
commit -m "feat: :card_file_box: add component \"${NAME}\" from Issue #${ISSUE_NUMBER}"
git push origin $BRANCH_NAME
- name: 'Create Pull Request'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
NAME="${{ steps.issue-parser.outputs.issueparser_name }}"
SANITIZED_NAME=$(echo "$NAME" | tr '[:upper:]' '[:lower:]' | sed -e 's/[ \/]\+/-/g' -e 's/[^a-z0-9-]\+//g')
ISSUE_NUMBER="${{ github.event.issue.number }}"
BRANCH_NAME="new/component-${ISSUE_NUMBER}-${SANITIZED_NAME}"
# Create the PR using the GitHub CLI
gh pr create \
--title ":card_file_box: Add component \"${NAME}\" from Issue #${ISSUE_NUMBER}" \
--body "Closes #${ISSUE_NUMBER}. This PR was automatically generated." \
--base develop \
--head $BRANCH_NAME