|
| 1 | +name: Approve or Deny Marketplace Action Request |
| 2 | + |
| 3 | +on: |
| 4 | + issue_comment: |
| 5 | + types: [created] |
| 6 | + |
| 7 | +jobs: |
| 8 | + parse-issue: |
| 9 | + runs-on: self-hosted |
| 10 | + outputs: |
| 11 | + payload: ${{ steps.issue_body_parser_request.outputs.payload }} |
| 12 | + steps: |
| 13 | + - name: Get JSON Data out of Issue Request |
| 14 | + uses: peter-murray/issue-body-parser-action@v2 |
| 15 | + id: issue_body_parser_request |
| 16 | + with: |
| 17 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 18 | + issue_id: ${{ github.event.issue.number }} |
| 19 | + payload_marker: request |
| 20 | + fail_on_missing: false |
| 21 | + approve-or-deny-request: |
| 22 | + runs-on: self-hosted |
| 23 | + needs: parse-issue |
| 24 | + if: needs.parse-issue.outputs.payload != 'NOT_FOUND' |
| 25 | + steps: |
| 26 | + - name: Lookup the latest release of ${{ fromJson(needs.parse-issue.outputs.payload).owner }}/${{ fromJson(needs.parse-issue.outputs.payload).repo }} |
| 27 | + id: get_version |
| 28 | + env: |
| 29 | + OWNER: ${{ fromJson(needs.parse-issue.outputs.payload).owner }} |
| 30 | + REPO: ${{ fromJson(needs.parse-issue.outputs.payload).repo }} |
| 31 | + REQUEST_VERSION: ${{ fromJson(needs.parse-issue.outputs.payload).version }} |
| 32 | + run: | |
| 33 | + if [ $REQUEST_VERSION == 'latest' ]; then |
| 34 | + echo "Finding latest release of $OWNER/$REPO..." |
| 35 | + export VERSION=`curl https://api.github.com/repos/$OWNER/$REPO/releases/latest | jq -r .name` |
| 36 | + else |
| 37 | + export VERSION=$REQUEST_VERSION |
| 38 | + fi |
| 39 | + echo "VERSION: $VERSION" |
| 40 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 41 | + - name: Check out scripts |
| 42 | + uses: actions/checkout@v3 |
| 43 | + - name: Setup Node |
| 44 | + uses: actions/setup-node@v3 |
| 45 | + with: |
| 46 | + node-version: '14' |
| 47 | + check-latest: true |
| 48 | + - name: Install dependencies |
| 49 | + run: | |
| 50 | + cd .github/scripts |
| 51 | + npm install |
| 52 | + - name: Approve or deny request |
| 53 | + uses: actions/github-script@main |
| 54 | + env: |
| 55 | + VERSION: ${{ steps.get_version.outputs.version }} |
| 56 | + with: |
| 57 | + debug: true |
| 58 | + script: | |
| 59 | + const options = { token: '${{ secrets.TOKEN }}', adminOpsOrg: '${{ vars.ADMIN_OPS_ORG }}', actionsApprovedOrg: '${{ vars.ACTIONS_APPROVED_ORG }}', actionsApproverTeam: '${{ vars.ACTIONS_APPROVERS_TEAM }}', baseUrl: '${{ github.api_url }}', version: process.env.VERSION }; |
| 60 | + const payload = ${{ needs.parse-issue.outputs.payload }} |
| 61 | + await require('./.github/scripts/approve-or-deny-request.js')({github, context, payload, options}); |
0 commit comments