-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add GA template to download contracts
- Loading branch information
1 parent
f1b9da5
commit 0d82194
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: "Download From Contract" | ||
description: "Download tokens & contracts files from contract repository" | ||
|
||
inputs: | ||
type: | ||
description: "version type of files (for example public-soft-launch)" | ||
required: true | ||
tag: | ||
description: "which version of contracts release will be downloaded? [Default: last one]" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Fetch Contract Links | ||
shell: bash | ||
id: version | ||
run: | | ||
if [ -z "${{inputs.tag}}" ] | ||
then | ||
echo "download_version=$(echo $(curl -s https://api.github.com/repos/rosen-bridge/contract/releases) | jq -r 'max_by(.published_at).name')" >> $GITHUB_OUTPUT | ||
elif [ "$(echo "${{inputs.tag}}" | tr '[:upper:]' '[:lower:]')" == "latest" ] | ||
then | ||
echo "download_version=$(echo $(curl -s https://api.github.com/repos/rosen-bridge/contract/releases/latest) | jq -r '.tag_name')" >> $GITHUB_OUTPUT | ||
else | ||
echo "download_version=$(echo "${{inputs.tag}}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Download Contracts Files | ||
shell: bash | ||
run: | | ||
release_info=$(curl -s "https://api.github.com/repos/rosen-bridge/contract/releases/tags/${{steps.version.outputs.download_version}}") | ||
asset_urls=$(echo "$release_info" | jq -r --arg name "${{inputs.type}}" '.assets | map(select(.name | test($name))) | .[].browser_download_url') | ||
for url in $asset_urls; do | ||
curl -LJO "$url" | ||
done | ||
mv ./tokensMap-${{inputs.type}}-${{steps.version.outputs.download_version}}.json ./tokens.json | ||
files=$(ls contracts-*-${{inputs.type}}-${{steps.version.outputs.download_version}}.json) | ||
for file in $files; do | ||
new_name=$(echo "$file" | awk -F'-' '{print $1"-"$2"-mainnet.json"}') | ||
mv "$file" "$new_name" | ||
done |