@adobe/workfront-ui-ext-tpl #882
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: Template Removal | |
defaults: | |
run: | |
shell: bash | |
on: | |
issues: | |
types: [labeled] | |
issue_comment: | |
types: [created] | |
jobs: | |
parse-issue-form-body: | |
name: Parse Issue Form Body | |
runs-on: ubuntu-latest | |
if: (github.event.label.name == 'remove-template') || (github.event_name == 'issue_comment' && github.event.comment.body == '/remove') | |
outputs: | |
npm-package: ${{ steps.parse-issue-form-body.outputs.npm-package }} | |
error: ${{ steps.parse-issue-form-body.outputs.error }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Use node 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
run: npm install | |
- name: Parse Issue Form Body | |
id: parse-issue-form-body | |
run: | | |
node src/parse-issue-form-body.js 'removal-request' | |
env: | |
GITHUB_ISSUE_PAYLOAD: ${{ github.event.issue.body }} | |
set-owner-repo-user: | |
name: Set the owner, repo name and user login. | |
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 }} | |
user-login: ${{ steps.set-values.outputs.USER_LOGIN }} | |
steps: | |
- name: Set the owner, repo name and user login. | |
id: set-values | |
run: | | |
if ${{ github.event_name == 'issue_comment' }} | |
then | |
echo "USER_LOGIN=${{ github.event.comment.user.login }}" >> $GITHUB_OUTPUT | |
else | |
echo "USER_LOGIN=${{ github.event.issue.user.login }}" >> $GITHUB_OUTPUT | |
fi | |
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-user] | |
uses: ./.github/workflows/check-permissions-workflow.yml | |
secrets: | |
ALLOWLIST_ADMINS: ${{ secrets.ALLOWLIST_ADMINS }} | |
with: | |
user-login: ${{ needs.set-owner-repo-user.outputs.user-login }} | |
npm-package: ${{ needs.parse-issue-form-body.outputs.npm-package }} | |
github-repo-owner: ${{ needs.set-owner-repo-user.outputs.github-repo-owner }} | |
github-repo: ${{ needs.set-owner-repo-user.outputs.github-repo }} | |
remove-from-registry: | |
name: Remove template from registry | |
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.check-permissions.outputs.is-admin == 'true' || needs.check-permissions.outputs.is-owner == 'true') }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Use node 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- 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/[email protected] | |
with: | |
add: registry.json | |
default_author: github_actions | |
message: Remove ${{ needs.parse-issue-form-body.outputs.npm-package }} template from Template Registry | |
push: true | |
success-close-issue: | |
name: Close issue | |
runs-on: ubuntu-latest | |
needs: [remove-from-registry] | |
steps: | |
- uses: peter-evans/close-issue@v2 | |
with: | |
comment: "The template has been removed from Template Registry." | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fail-removal-comment: | |
name: Removal failed | |
runs-on: ubuntu-latest | |
needs: [parse-issue-form-body, check-permissions, remove-from-registry] | |
if: ${{ always() && (needs.parse-issue-form-body.result == 'failure' || (needs.parse-issue-form-body.result != 'skipped' && (needs.remove-from-registry.outputs.error != '' || (needs.check-permissions.outputs.is-admin != 'true' && needs.check-permissions.outputs.is-owner != 'true' && (needs.check-permissions.outputs.is-admin-error != '' || needs.check-permissions.outputs.is-owner-error != ''))))) }} | |
steps: | |
- uses: peter-evans/[email protected] | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
body: | | |
### Failed Checks | |
${{ needs.parse-issue-form-body.outputs.error }} | |
${{ needs.check-permissions.outputs.is-admin-error }} | |
${{ needs.check-permissions.outputs.is-owner-error }} | |
${{ needs.remove-from-registry.outputs.error }} | |
Fix all mentioned issues and comment `/remove` to try again. | |
token: ${{ secrets.GITHUB_TOKEN }} |