-
Notifications
You must be signed in to change notification settings - Fork 63
43 lines (35 loc) · 1.71 KB
/
push-tokens.yaml
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
name: Update tokenlist.json in DragonSwap Client
on:
pull_request:
types:
- opened
- synchronize
jobs:
updateTokenList:
runs-on: ubuntu-latest
steps:
- name: Check network access to raw.githubusercontent.com
run: |
curl -sSL -H "Authorization: token ${{ secrets.GH_TOKEN }}" \
"https://raw.githubusercontent.com/dragonswap-app/assets/main/tokenlist.json"
- name: Checkout code
uses: actions/checkout@v2
- name: Update tokenlist.json in DragonSwap Client
run: |
# Set up necessary variables
SOURCE_REPO_OWNER=dragonswap-app
SOURCE_REPO_NAME=assets
SOURCE_FILE_PATH=tokenlist.json
TARGET_REPO_OWNER=NIMA-Enterprises
TARGET_REPO_NAME=dragonswap-client
TARGET_FILE_PATH=apps/dragon-swap/tokenlist.json
GITHUB_TOKEN=${{ secrets.GH_TOKEN }}
SOURCE_FILE_CONTENT=$(curl -sSL -H "Authorization: token ${{ secrets.GH_TOKEN }}" \
"https://raw.githubusercontent.com/dragonswap-app/assets/main/tokenlist.json")
# Update tokenlist.json in the target repo
curl -sSL -X PUT -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"message": "Update tokenlist.json via GitHub Action", "content": "'$(echo "$SOURCE_FILE_CONTENT" | base64)'", "sha": "'$(curl -sSL -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$TARGET_REPO_OWNER/$TARGET_REPO_NAME/contents/$TARGET_FILE_PATH" | jq -r '.sha')'"}' \
"https://api.github.com/repos/$TARGET_REPO_OWNER/$TARGET_REPO_NAME/contents/$TARGET_FILE_PATH"
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}