-
Notifications
You must be signed in to change notification settings - Fork 25
72 lines (68 loc) · 2.24 KB
/
review-pending-deployments.yml
File metadata and controls
72 lines (68 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: 03-2. Review Pending Deployments (WIP)
on:
workflow_dispatch:
inputs:
run_id:
description: 'run_id'
required: true
default: ''
environment_ids:
description: 'environment_ids'
required: true
default: ''
state:
description: 'state'
required: true
default: 'approved'
type: choice
options:
- approved
- rejected
comment:
description: 'comment'
required: false
default: 'approved'
# Limit the permissions of the GITHUB_TOKEN
permissions:
contents: read
deployments: read
actions: write
jobs:
review_pending_deployments:
name: ${{github.event.inputs.state}} pending deployments
runs-on: ubuntu-latest
steps:
- name: Get Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v3
with:
application_id: ${{ secrets.GH_ABCS_APP_ACTIONS_APP_ID }}
application_private_key: "${{ secrets.GH_ABCS_APP_ACTIONS_APP_PRIVATE_KEY }}"
permissions: "actions:write,contents:read,deployments:read"
- name: Get pending deployments
uses: actions/github-script@v7
with:
github-token: ${{steps.get_workflow_token.outputs.token}}
script: |
const result = await github.rest.actions.getPendingDeploymentsForRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.inputs.run_id}}
})
console.log(result.data[0].environment)
- name: ${{github.event.inputs.state}}
uses: actions/github-script@v7
with:
#github-token: ${{steps.get_workflow_token.outputs.token}}
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.actions.reviewPendingDeploymentsForRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.inputs.run_id}},
environment_ids: [
${{github.event.inputs.environment_ids}}
],
state: '${{github.event.inputs.state}}',
comment: '${{github.event.inputs.comment}}'
})