AEM Assets View Template Review #585
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: Template Rejection for 3rd Party Templates | |
| defaults: | |
| run: | |
| shell: bash | |
| on: | |
| issue_comment: | |
| types: [created] | |
| jobs: | |
| parse-issue-form-body: | |
| name: Parse issue form body | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'issue_comment' && github.event.comment.body == '/decline' && (contains(github.event.issue.labels.*.name, 'add-template') || contains(github.event.issue.labels.*.name, 'update-template')) | |
| outputs: | |
| github-link: ${{ steps.parse-issue-form-body.outputs.github-link }} | |
| npm-package: ${{ steps.parse-issue-form-body.outputs.npm-package }} | |
| error: ${{ steps.parse-issue-form-body.outputs.error }} | |
| request-type: ${{ steps.get-type.outputs.REQUEST_TYPE }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Use node 24 | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Get type of request | |
| id: get-type | |
| run: | | |
| if ${{ contains(github.event.issue.labels.*.name, 'add-template') }} | |
| then | |
| echo "REQUEST_TYPE=review-request" >> $GITHUB_OUTPUT | |
| fi | |
| if ${{ contains(github.event.issue.labels.*.name, 'update-template') }} | |
| then | |
| echo "REQUEST_TYPE=update-request" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Parse issue form body | |
| id: parse-issue-form-body | |
| run: | | |
| node src/parse-issue-form-body.js ${{ steps.get-type.outputs.REQUEST_TYPE }} | |
| env: | |
| GITHUB_ISSUE_PAYLOAD: ${{ github.event.issue.body }} | |
| set-owner-repo: | |
| name: Set the owner and repo name. | |
| runs-on: ubuntu-latest | |
| needs: [parse-issue-form-body] | |
| outputs: | |
| github-repo-owner: ${{ steps.set-values.outputs.GITHUB_REPO_OWNER }} | |
| github-repo: ${{ steps.set-values.outputs.GITHUB_REPO }} | |
| steps: | |
| - name: Set the owner and repo name. | |
| id: set-values | |
| run: | | |
| ownerRepo='${{ github.repository }}' | |
| owner='${{ github.repository_owner }}' | |
| echo "GITHUB_REPO_OWNER=$owner" >> $GITHUB_OUTPUT | |
| github_repo=${ownerRepo#"$owner/"} | |
| echo "GITHUB_REPO=$github_repo" >> $GITHUB_OUTPUT | |
| check-permissions: | |
| needs: [parse-issue-form-body, set-owner-repo] | |
| uses: ./.github/workflows/check-permissions-workflow.yml | |
| with: | |
| user-login: ${{ github.event.comment.user.login }} | |
| update-request-rejected: | |
| name: Update template status to rejected if approval declined on update request | |
| runs-on: ubuntu-latest | |
| needs: [parse-issue-form-body, check-permissions] | |
| if: ${{ always() && needs.parse-issue-form-body.result == 'success' && needs.parse-issue-form-body.outputs.request-type == 'update-request' && needs.check-permissions.outputs.is-admin == 'true' }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Use node 24 | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Change registry.json | |
| id: run-update-template | |
| run: | | |
| npm v ${{ needs.parse-issue-form-body.outputs.npm-package }} dist.tarball | xargs curl | tar -xz | |
| node src/update-template.js $GITHUB_WORKSPACE/package ${{ needs.parse-issue-form-body.outputs.github-link }} ${{ needs.parse-issue-form-body.outputs.npm-package }} 'Rejected' | |
| - name: Commit and push changes | |
| uses: EndBug/add-and-commit@v9.1.1 | |
| with: | |
| add: registry.json | |
| default_author: github_actions | |
| message: Decline ${{ needs.parse-issue-form-body.outputs.npm-package }} template in Template Registry | |
| push: true | |
| update-request-close-issue: | |
| name: Close update-template issue after template declined | |
| runs-on: ubuntu-latest | |
| needs: [update-request-rejected] | |
| steps: | |
| - uses: peter-evans/close-issue@v2 | |
| with: | |
| comment: "Full approval not granted. Closing issue..." | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| add-request-remove-template: | |
| name: Remove template from registry if approval declined on new template | |
| runs-on: ubuntu-latest | |
| outputs: | |
| error: ${{ steps.run-remove-from-registry.outputs.error }} | |
| needs: [parse-issue-form-body, check-permissions] | |
| if: ${{ always() && needs.parse-issue-form-body.result == 'success' && needs.parse-issue-form-body.outputs.request-type == 'review-request' && needs.check-permissions.outputs.is-admin == 'true' }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Use node 24 | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Change registry.json | |
| id: run-remove-from-registry | |
| run: node src/remove-from-registry.js ${{ needs.parse-issue-form-body.outputs.npm-package }} | |
| - name: Commit and push changes | |
| uses: EndBug/add-and-commit@v9.1.1 | |
| with: | |
| add: registry.json | |
| default_author: github_actions | |
| message: Remove ${{ needs.parse-issue-form-body.outputs.npm-package }} template from Template Registry | |
| push: true | |
| add-request-close-issue: | |
| name: Close issue after removing template from registry | |
| runs-on: ubuntu-latest | |
| needs: [add-request-remove-template] | |
| steps: | |
| - uses: peter-evans/close-issue@v2 | |
| with: | |
| comment: "The template has been declined and removed from Template Registry. To try again, open a new review request." | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fail-removal-comment: | |
| name: Removal failed | |
| runs-on: ubuntu-latest | |
| needs: [parse-issue-form-body, check-permissions, add-request-remove-template] | |
| if: ${{ always() && (needs.parse-issue-form-body.result == 'failure' || (needs.parse-issue-form-body.result != 'skipped' && (needs.add-request-remove-template.outputs.error != '' || (needs.check-permissions.outputs.is-admin != 'true' && needs.check-permissions.outputs.is-admin-error != '')))) }} | |
| steps: | |
| - uses: peter-evans/create-or-update-comment@v3.0.2 | |
| with: | |
| issue-number: ${{ github.event.issue.number }} | |
| body: | | |
| Unable to decline template: | |
| ${{ needs.parse-issue-form-body.outputs.error }} | |
| ${{ needs.check-permissions.outputs.is-admin-error }} | |
| ${{ needs.add-request-remove-template.outputs.error }} | |
| Fix all mentioned issues and comment `/decline` to try again. | |
| token: ${{ secrets.GITHUB_TOKEN }} |