-
Notifications
You must be signed in to change notification settings - Fork 28
131 lines (106 loc) · 5.59 KB
/
processRequest.yml
File metadata and controls
131 lines (106 loc) · 5.59 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Process Token Request
# Handles token addition, removal, and image optimization requests
# Validates input, processes images, and creates PRs with appropriate reviewers
on:
issues:
types: [opened]
env:
FIELD_NAMES: 'Network,Symbol,Name,URL,Decimals,Address,Reason'
IMAGES_BASE_PATH: src/public/images/
LIST_PATH: src/public/CowSwap.json
jobs:
process-request:
runs-on: ubuntu-latest
outputs:
operation: ${{ steps.extract-info.outputs.operation }}
issueInfo: ${{ steps.extract-info.outputs.issueInfo }}
needsImageOptimization: ${{ steps.extract-info.outputs.needsImageOptimization }}
if: contains(github.event.issue.labels.*.name, 'addImage') || contains(github.event.issue.labels.*.name, 'addToken') || contains(github.event.issue.labels.*.name, 'removeToken')
steps:
- name: Acknowledge request
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
with:
issue-number: ${{ github.event.issue.number }}
body: |
🔄 Your request has been received and is being processed.
This issue will be updated when completed.
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Extract and validate issue information
id: extract-info
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
script:
const { processRequest } = await import("${{github.workspace}}/scripts/processRequest.mjs");
processRequest(context, core);
- name: Handle validation errors
if: failure()
uses: peter-evans/close-issue@276d7966e389d888f011539a86c8920025ea0626
with:
comment: |
❌ **Invalid request**
Validation failed. Please check all required fields are provided and submit a new issue.
optimize-image:
needs: process-request
if: needs.process-request.outputs.needsImageOptimization == 'true'
uses: ./.github/workflows/optimizeImage.yml
with:
url: ${{ fromJSON(needs.process-request.outputs.issueInfo).url }}
address: ${{ fromJSON(needs.process-request.outputs.issueInfo).address }}
execute-add-token:
needs: [process-request, optimize-image]
if: needs.process-request.outputs.operation == 'addToken'
uses: ./.github/workflows/executeAction.yml
secrets: inherit
with:
issueInfo: ${{ needs.process-request.outputs.issueInfo }}
operation: addToken
prTitle: '[addToken] `${{ fromJSON(needs.process-request.outputs.issueInfo).symbol }}` to `${{ fromJSON(needs.process-request.outputs.issueInfo).network }}`'
prBody: |
Adding token `${{ fromJSON(needs.process-request.outputs.issueInfo).symbol }}` on network `${{ fromJSON(needs.process-request.outputs.issueInfo).network }}`
**Address**: `${{ fromJSON(needs.process-request.outputs.issueInfo).address }}`
[Link to block explorer ↗︎](https://${{ fromJSON(needs.process-request.outputs.issueInfo).blockExplorer }}/token/${{ fromJSON(needs.process-request.outputs.issueInfo).address }})
| Description | Image |
|-|-|
| Original | .url }}) |
| Optimized | .prImageUrl, 'addToken') }}) |
### Reason
```
${{ fromJSON(needs.process-request.outputs.issueInfo).reason }}
```
execute-remove-token:
needs: process-request
if: needs.process-request.outputs.operation == 'removeToken'
uses: ./.github/workflows/executeAction.yml
secrets: inherit
with:
issueInfo: ${{ needs.process-request.outputs.issueInfo }}
operation: removeToken
prTitle: '[removeToken] `${{ fromJSON(needs.process-request.outputs.issueInfo).address }}` from `${{ fromJSON(needs.process-request.outputs.issueInfo).network }}`'
prBody: |
Removing token from network `${{ fromJSON(needs.process-request.outputs.issueInfo).network }}`
**Address**: `${{ fromJSON(needs.process-request.outputs.issueInfo).address }}`
[Link to block explorer ↗︎](https://${{ fromJSON(needs.process-request.outputs.issueInfo).blockExplorer }}/token/${{ fromJSON(needs.process-request.outputs.issueInfo).address }})
### Reason
```
${{ fromJSON(needs.process-request.outputs.issueInfo).reason }}
```
execute-add-image:
needs: [process-request, optimize-image]
if: needs.process-request.outputs.operation == 'addImage'
uses: ./.github/workflows/executeAction.yml
secrets: inherit
with:
issueInfo: ${{ needs.process-request.outputs.issueInfo }}
operation: addImage
prTitle: '[addImage] `${{ fromJSON(needs.process-request.outputs.issueInfo).address }}` to `${{ fromJSON(needs.process-request.outputs.issueInfo).network }}`'
prBody: |
Adding image to network `${{ fromJSON(needs.process-request.outputs.issueInfo).network }}`
**Address**: `${{ fromJSON(needs.process-request.outputs.issueInfo).address }}`
[Link to block explorer ↗︎](https://${{ fromJSON(needs.process-request.outputs.issueInfo).blockExplorer }}/token/${{ fromJSON(needs.process-request.outputs.issueInfo).address }})
| Description | Image |
|-|-|
| Original | .url }}) |
| Optimized | .prImageUrl, 'addImage') }}) |