Check Extensions Summary #278
This file contains hidden or 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: Check Extensions Summary | |
| on: | |
| workflow_dispatch: | |
| workflow_run: | |
| workflows: | |
| - "Check Extensions" | |
| types: | |
| - completed | |
| permissions: | |
| pull-requests: write | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event_name }} | |
| cancel-in-progress: true | |
| jobs: | |
| check-summary: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Create GitHub App token | |
| uses: actions/create-github-app-token@v3 | |
| id: app-token | |
| with: | |
| client-id: ${{ vars.APP_ID }} | |
| private-key: ${{ secrets.APP_KEY }} | |
| - name: Download artifact | |
| id: download-artifact | |
| continue-on-error: true | |
| uses: actions/download-artifact@v8.0.1 | |
| with: | |
| name: extensions-check-summary | |
| path: "${{ runner.temp }}/artifacts/" | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ steps.app-token.outputs.token }} | |
| - name: Generate summary report | |
| if: steps.download-artifact.outputs.download-path != '' | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| DOWNLOAD_PATH: ${{ steps.download-artifact.outputs.download-path }} | |
| shell: bash | |
| run: | | |
| gh pr comment "$(cat "${DOWNLOAD_PATH}/pr_number")" \ | |
| --body-file "${DOWNLOAD_PATH}/summary.md" \ | |
| --create-if-none \ | |
| --edit-last \ | |
| --repo "${GITHUB_REPOSITORY}" | |
| cat "${DOWNLOAD_PATH}/summary.md" >> "${GITHUB_STEP_SUMMARY}" | |
| - name: Normalise title and label | |
| if: steps.download-artifact.outputs.download-path != '' | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| DOWNLOAD_PATH: ${{ steps.download-artifact.outputs.download-path }} | |
| shell: bash | |
| run: | | |
| PR_NUMBER=$(cat "${DOWNLOAD_PATH}/pr_number") | |
| TITLE=$(gh pr view "${PR_NUMBER}" --repo "${GITHUB_REPOSITORY}" --json title --jq .title) | |
| LOWER=$(echo "${TITLE}" | tr '[:upper:]' '[:lower:]') | |
| if echo "${LOWER}" | grep -qE '^[a-z]+(\([^)]*\))?!?:[[:space:]]'; then | |
| NEW_TITLE="${LOWER}" | |
| else | |
| NEW_TITLE="chore: ${LOWER}" | |
| fi | |
| args=(--add-label "Type: Valorisation :tada:") | |
| if [[ "${TITLE}" != "${NEW_TITLE}" ]]; then | |
| args+=(--title "${NEW_TITLE}") | |
| fi | |
| gh pr edit "${PR_NUMBER}" --repo "${GITHUB_REPOSITORY}" "${args[@]}" | |
| - name: Workflow completion | |
| env: | |
| DOWNLOAD_PATH: ${{ steps.download-artifact.outputs.download-path }} | |
| run: | | |
| if [[ "${DOWNLOAD_PATH}" == "" ]]; then | |
| echo "ℹ️ No artifacts found, workflow completed successfully" | |
| echo "ℹ️ No artifacts found, workflow completed successfully" >> "${GITHUB_STEP_SUMMARY}" | |
| fi |