Update token list #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update tokenlist.json in DragonSwap Client | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
jobs: | |
updateTokenList: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: "Setup jq" | |
uses: dcarbone/install-jq-action@v2 | |
with: | |
version: "1.7" | |
- name: "Check jq" | |
# language=sh | |
run: | | |
which jq | |
jq --version | |
- 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 }} | |
sudo apt-get update && sudo apt-get install -y jq | |
TARGET_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') | |
SOURCE_FILE_CONTENT=$(curl -sSL -H "Authorization: Bearer $GITHUB_TOKEN" "https://raw.githubusercontent.com/$SOURCE_REPO_OWNER/$SOURCE_REPO_NAME/main/$SOURCE_FILE_PATH" | base64) | |
PAYLOAD='{"message": "Update tokenlist.json via GitHub Action", "content": "'$SOURCE_FILE_CONTENT'", "sha": "'$TARGET_SHA'"}' | |
# Update tokenlist.json in the target repo | |
curl -sSL -X PUT -H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-d "$PAYLOAD" \ | |
"https://api.github.com/repos/$TARGET_REPO_OWNER/$TARGET_REPO_NAME/contents/$TARGET_FILE_PATH" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |