1+ name : ExecuteAction
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ issueInfo :
7+ required : true
8+ type : string
9+ operation :
10+ required : true
11+ type : string
12+ prTitle :
13+ required : true
14+ type : string
15+ prBody :
16+ required : true
17+ type : string
18+
19+ env :
20+ IMAGES_BASE_PATH : src/public/images/
21+ LIST_PATH : src/public/CowSwap.json
22+
23+ jobs :
24+ execute :
25+ runs-on : ubuntu-latest
26+ steps :
27+
28+ - name : Checkout code
29+ uses : actions/checkout@v3
30+
31+ - name : Set BASE_PATH env var
32+ run : echo "BASE_PATH=${{ env.IMAGES_BASE_PATH }}${{ fromJSON(inputs.issueInfo).chainId }}/${{ fromJSON(inputs.issueInfo).address }}/" >> "$GITHUB_ENV"
33+
34+ - name : Create base path and info.json if it doesn't exist
35+ run : |
36+ mkdir -p ${{ env.BASE_PATH }}
37+ touch "${{ env.BASE_PATH }}info.json"
38+
39+ - name : Save input into local file
40+ run : |
41+ cat << EOF > data.json
42+ ${{ inputs.issueInfo }}
43+ EOF
44+
45+ # Image handling
46+ - name : Download image
47+ if : ${{ inputs.operation == 'addImage' || inputs.operation == 'addToken' }}
48+ uses : actions/download-artifact@v3
49+ with :
50+ name : ${{ fromJSON(inputs.issueInfo).address }}
51+
52+ - name : Move image to destination
53+ if : ${{ inputs.operation == 'addImage' || inputs.operation == 'addToken' }}
54+ run : mv output.png ${{ env.BASE_PATH }}logo.png
55+
56+ - name : Update json files
57+ run : python3 src/scripts/workflow_helper.py ${{ inputs.operation }} data.json
58+
59+ - name : Create Pull Request
60+ id : cpr
61+ uses : peter-evans/create-pull-request@v4
62+ with :
63+ commit-message : " [${{ inputs.operation }}] ${{ fromJSON(inputs.issueInfo).network }}/${{ fromJSON(inputs.issueInfo).address }}"
64+ branch : ${{ inputs.operation }}/${{ fromJSON(inputs.issueInfo).chainId }}_${{ fromJSON(inputs.issueInfo).address }}
65+ delete-branch : true
66+ title : ${{ inputs.prTitle }}
67+ body : |
68+ # ${{ inputs.operation }}
69+
70+ **Note** This is an automated PR
71+
72+ Submitted by @${{ github.event.issue.user.login }}
73+
74+ Closes #${{ github.event.issue.number }}
75+
76+ ---
77+
78+ ${{ inputs.prBody }}
79+ add-paths : |
80+ ${{ env.BASE_PATH }}/*
81+ ${{ env.LIST_PATH }}
82+
83+ - name : Comment on issue
84+ uses : peter-evans/create-or-update-comment@v2
85+ with :
86+ issue-number : ${{ github.event.issue.number }}
87+ body : |
88+ Your request is ready and will be reviewed by a team member.
89+ You can follow the progress in the Pull Request #${{ steps.cpr.outputs.pull-request-number }}
90+
91+ - name : Report error
92+ if : ${{ failure() }}
93+ uses : peter-evans/close-issue@v2
94+ with :
95+ comment : |
96+ Failed to ${{ inputs.operation }}
97+
98+ Check the input is correct and try again in a new issue
99+
100+ If the issue persists, create a bug report
101+
102+ cc @cowprotocol/frontend
0 commit comments