Skip to content

Commit

Permalink
Update tokenlist.json via GitHub Action
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko authored and Marko committed Jan 24, 2024
1 parent b30b7e4 commit 15f161d
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/push-tokens.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@ jobs:
- 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")
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: Bearer $GITHUB_TOKEN" \
"https://raw.githubusercontent.com/$SOURCE_REPO_OWNER/$SOURCE_REPO_NAME/main/$SOURCE_FILE_PATH")
# 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)'"}' \
-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:
Expand Down

0 comments on commit 15f161d

Please sign in to comment.