diff --git a/.github/workflows/package-development-workflow.yml b/.github/workflows/package-development-workflow.yml index 93e4ee0..7e12198 100644 --- a/.github/workflows/package-development-workflow.yml +++ b/.github/workflows/package-development-workflow.yml @@ -7,7 +7,6 @@ on: push: branches: - 'main' # runs the workflow, once new changes have been integrated to main - - 'main/**' # runs the workflow, once new changes have been integrated to a sub-branch of main pull_request: branches: - 'main' # run workflow in the scope of pull requests towards main diff --git a/template/.github/workflows/generate-assessment-artifacts.yml b/template/.github/workflows/generate-assessment-artifacts.yml new file mode 100644 index 0000000..509f222 --- /dev/null +++ b/template/.github/workflows/generate-assessment-artifacts.yml @@ -0,0 +1,158 @@ + +# This GitHub Actions workflow generates an assessment Excel file for SIMATIC AX projects +# and automatically creates an issue with download links and notification emails. +# +# Workflow Structure: +# 1. collect-info: Gathers project information and creates info.yml artifact +# 2. fill-excel: Downloads info, generates Excel file, and uploads as artifact +# 3. notify: Creates GitHub issue with download links and email notification +# +# The workflow is triggered manually via workflow_dispatch with two required inputs: +# - EXACT_Ticket_ID: The EX Classification Ticket number +# - Approver: The business approver (Promotor BL) selected from predefined options +# +# Artifacts generated: +# - info-yml: Contains collected project information +# - assessment-excel: The generated questionnaire Excel file +# +# The final issue includes direct links to the workflow run for artifact download +# and a mailto link for email notification to the actor. + +name: Start Assessment +on: + workflow_dispatch: + inputs: + EXACT_Ticket_ID: + description: 'Your EX Classification Ticket' + required: true + default: '0000' + Approver: + description: 'Promotor BL (Approver from Business Side to release)' + required: true + type: string + +jobs: + # Job 1: Collect project information and create info.yml artifact + # Uses simatic-ax internal action to gather project details, ticket info, and approver data + collect-info: + runs-on: ubuntu-latest + steps: + # Checkout the repository to access project files + - name: Checkout repository + uses: actions/checkout@v4 + + # Set up Python environment for the collection script + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + # Install required Python dependencies for info collection + - name: Install Python dependencies + run: | + python3 -m pip install requests pyyaml openpyxl + + # Collect project information using internal Simatic AX action + # This creates an info.yml file with project details, ticket ID, and approver + - name: Collect Info + uses: simatic-ax/internal-actions/collect-assessment-information@v1 + with: + project_name: ${{ github.repository }} + username: ${{ github.actor }} + token: ${{ secrets.READ_USER_TOKEN }} + ticket_id: ${{ inputs.EXACT_Ticket_ID }} + approver: ${{ inputs.Approver }} + + # Upload the generated info.yml as an artifact for use in subsequent jobs + - name: Upload info.yml + uses: actions/upload-artifact@v3 + with: + name: info-yml + path: info.yml + + # Job 2: Generate the assessment Excel file using the collected information + # Downloads info.yml artifact and creates the questionnaire Excel file + fill-excel: + runs-on: ubuntu-latest + needs: collect-info # Wait for info collection to complete + steps: + # Checkout repository for Excel generation scripts + - name: Checkout repository + uses: actions/checkout@v4 + + # Set up Python environment for Excel generation + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + # Install Python dependencies required for Excel file creation + - name: Install Python dependencies + run: | + python3 -m pip install requests pyyaml openpyxl + + # Download the info.yml artifact created in the previous job + - name: Download info.yml + uses: actions/download-artifact@v3 + with: + name: info-yml + + # Generate the assessment Excel file using internal Simatic AX action + # This creates a Questionnaire_Contribution_*.xlsx file + - name: Create Assessment Excel-File + uses: simatic-ax/internal-actions/create-assessment-excel@v1 + + # Upload the generated Excel file as an artifact for download + - name: Upload Excel artifact + uses: actions/upload-artifact@v3 + with: + name: assessment-excel + path: Questionnaire_Contribution_*.xlsx + + # Print workflow run information for reference + # Note: Artifacts are only available via API after complete workflow finish + - name: Print Run ID after Excel artifact upload + run: | + echo "Aktuelle Run ID: ${{ github.run_id }}" + echo "Excel artifact wird nach Workflow-Ende verfügbar sein unter:" + echo "https://github.siemens.cloud/${{ github.repository }}/actions/runs/${{ github.run_id }}" + + # Job 4: Trigger notification workflow with direct artifact links + # This job calls the separate notify-assessment workflow to create detailed issues with artifact download links + trigger-notify: + runs-on: ubuntu-latest + needs: fill-excel # Wait for notify to complete + steps: + # Download info.yml to extract ticket information for notification + - name: Download info.yml + uses: actions/download-artifact@v3 + with: + name: info-yml + + # Extract ticket ID and email for notification content + - name: Extract notification info + id: extract-info + run: | + SCD_MAIL=$(cat info.yml | grep scd_mail | awk '{print $2}') + TICKET_ID=$(cat info.yml | grep ticket_id | awk '{print $2}') + echo "scd_mail=$SCD_MAIL" >> $GITHUB_OUTPUT + echo "ticket_id=$TICKET_ID" >> $GITHUB_OUTPUT + + # Trigger the separate notification workflow with direct artifact links + - name: Trigger notification workflow + run: | + ISSUE_TITLE="Assessment Excel Ready - Direct Downloads (Ticket: ${{ steps.extract-info.outputs.ticket_id }})" + ISSUE_BODY="🎯 **Assessment Excel Generation Complete**\n\nTicket ID: **${{ steps.extract-info.outputs.ticket_id }}**\nTriggered by: **${{ github.actor }}**\n\n📧 **Quick Email Notification:**\n[Send email to ${{ steps.extract-info.outputs.scd_mail }}](mailto:${{ steps.extract-info.outputs.scd_mail }}?subject=Assessment%20Excel%20Ready%20-%20Ticket%20${{ steps.extract-info.outputs.ticket_id }}&body=Hello,%0A%0AYour%20assessment%20Excel%20file%20has%20been%20generated%20successfully.%0A%0ATicket:%20${{ steps.extract-info.outputs.ticket_id }}%0AWorkflow%20Run:%20https://github.siemens.cloud/${{ github.repository }}/actions/runs/${{ github.run_id }}%0A%0APlease%20check%20the%20GitHub%20issue%20for%20direct%20download%20links.%0A%0ABest%20regards)" + + curl -X POST \ + -H "Authorization: token ${{ secrets.GH_ISSUE_CREATOR_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://github.siemens.cloud/api/v3/repos/${{ github.repository }}/actions/workflows/notify-assessment.yml/dispatches" \ + -d "{ + \"ref\": \"main\", + \"inputs\": { + \"run_id\": \"${{ github.run_id }}\", + \"repository\": \"${{ github.repository }}\", + \"actor\": \"${{ github.actor }}\" + } + }" \ No newline at end of file diff --git a/template/.github/workflows/notify-assessment-completion.yml b/template/.github/workflows/notify-assessment-completion.yml new file mode 100644 index 0000000..8709b03 --- /dev/null +++ b/template/.github/workflows/notify-assessment-completion.yml @@ -0,0 +1,72 @@ +# Notification workflow for assessment Excel file completion +# This workflow is triggered by the generate_assessment workflow to create +# GitHub issues with direct artifact download links after workflow completion. +# +# The workflow fetches artifacts from the specified run ID and creates +# direct download links for each artifact in the GitHub issue. + +name: 'Create Assessment Notification Issue' +description: 'Creates a GitHub issue with artifact download links for completed assessment workflows' + +on: + workflow_dispatch: + inputs: + run_id: + description: 'Run ID of the completed assessment workflow' + required: true + type: string + repository: + description: 'Repository name in format owner/repo' + required: true + type: string + actor: + description: 'GitHub username of the person who triggered the original workflow' + required: false + type: string + +jobs: + create-notification-issue: + runs-on: ubuntu-latest + steps: + # Download info.yml artifact from the specified workflow run + - name: Download info.yml artifact + run: | + # Get artifacts from the specified run + ARTIFACTS_JSON=$(curl -s -H "Authorization: token ${{ secrets.GH_ISSUE_CREATOR_TOKEN }}" \ + "https://github.siemens.cloud/api/v3/repos/${{ inputs.repository }}/actions/runs/${{ inputs.run_id }}/artifacts") + + # Find info-yml artifact + INFO_ARTIFACT_ID=$(echo "$ARTIFACTS_JSON" | jq -r '.artifacts[] | select(.name == "info-yml") | .id') + + if [ -n "$INFO_ARTIFACT_ID" ] && [ "$INFO_ARTIFACT_ID" != "null" ]; then + echo "Downloading info-yml artifact (ID: $INFO_ARTIFACT_ID)" + + # Download the artifact + curl -L -H "Authorization: token ${{ secrets.GH_ISSUE_CREATOR_TOKEN }}" \ + "https://github.siemens.cloud/api/v3/repos/${{ inputs.repository }}/actions/artifacts/$INFO_ARTIFACT_ID/zip" \ + -o info-yml.zip + + # Extract the zip file + unzip -q info-yml.zip + + if [ -f "info.yml" ]; then + echo "Successfully downloaded and extracted info.yml" + cat info.yml + else + echo "Warning: info.yml not found in artifact" + touch info.yml # Create empty file as fallback + fi + else + echo "Warning: info-yml artifact not found, creating empty info.yml" + touch info.yml + fi + + # Create GitHub issue using the new comprehensive action + - name: Create Assessment Notification Issue + uses: simatic-ax/internal-actions/create-assessment-issue@v1 + with: + run_id: ${{ inputs.run_id }} + info_file: info.yml + github_token: ${{ secrets.GH_ISSUE_CREATOR_TOKEN }} + repository: ${{ inputs.repository }} + actor: ${{ inputs.actor }} diff --git a/template/.github/workflows/package-development-workflow.yml b/template/.github/workflows/package-development-workflow.yml index 79cdaf5..edb0516 100644 --- a/template/.github/workflows/package-development-workflow.yml +++ b/template/.github/workflows/package-development-workflow.yml @@ -5,10 +5,10 @@ on: push: branches: - 'main' # runs the workflow, once new changes have been integrated to main - - 'main/**' # runs the workflow, once new changes have been integrated to a sub-branch of main pull_request: branches: - 'main' # run workflow in the scope of pull requests towards main + - 'release/*' # run workflow in the scope of pull requests towards release branches workflow_call: secrets: APAX_TOKEN: @@ -92,4 +92,4 @@ jobs: bin/1500 bin/llvm retention-days: 90 - if-no-files-found: error \ No newline at end of file + if-no-files-found: error diff --git a/template/README.md b/template/README.md index 25c67f5..7fc7c30 100644 --- a/template/README.md +++ b/template/README.md @@ -35,48 +35,6 @@ Using apax-package-name-d7b4b031; |-----------------|-----------------------| | *xyz* | *description for xyz* | -## Folder structure -```bash -apax-package-name-d7b4b031 - | - +- .github - | | # GitHub workflows for maintaining the library - | |- package-development-workflow.yml - | |- package-release-workflow.yml - | - +- docs - | | # the place for additional user-documentation - | |- MyClass.md - | - +- snippets - | | # may contain helpful snippets for using the library - | |- namespacesupport.json - | |- usingNamespace.json - | - +- src - | | # adjust and add library src files here - | |- myClass.st - | - +- test - | | # adjust and add test-programs here - | |- dummy.st - | - | # additional meta-information for GitHub/-workflows - |- .gitattributes - |- .gitignore - | - | # settings file for activating the renovate-bot - |- renovate.json - | - | # adjust the project description file / add apax-scripts - |- apax.yml - | - | # essential git project files, pls. adjust - |- CODEOWNERS - |- README.md - |- LICENSE.md #do not change! -``` - ## Contribution Thanks for your interest in contributing. Anybody is free to report bugs, unclear documentation, and other problems regarding this repository in the Issues section or, even better, is free to propose any changes to this repository using a pull request.