changed to be json #2
Workflow file for this run
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: Deploy wallet preview on request | |
on: | |
issue_comment: | |
types: [created] | |
env: | |
CI: false | |
jobs: | |
deploy_on_request: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if deployment is requested | |
id: check-comment | |
uses: actions/github-script@v4 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const keywords = ["pls deploy"]; | |
const comment = context.payload.comment.body; | |
const matches = keywords.some(keyword => comment.includes(keyword)); | |
return { matches }; | |
- name: Install jq | |
run: sudo apt-get update && sudo apt-get install -y jq | |
- name: Trigger workflow if deployment is requested | |
if: steps.check-comment.outputs.matches == true | |
run: | | |
# Extract JSON string from the comment | |
# Example comment: "pls deploy {"REACT_APP_NAMADA_ALIAS": "Namada Devnet", "REACT_APP_NAMADA_CHAIN_ID": "internal-devnet-6be.86067e06a5"}" | |
# Note: Make sure the comment format matches the pattern below | |
comment_text="${{ github.event.comment.body }}" | |
json_str=$(echo "$comment_text" | sed 's/.*{\(.*\)}.*$/\1/') | |
# Use jq to parse JSON string and set environment variables | |
alias=$(echo "$json_str" | jq -r '.REACT_APP_NAMADA_ALIAS // "Namada Devnet"') | |
chain_id=$(echo "$json_str" | jq -r '.REACT_APP_NAMADA_CHAIN_ID // "internal-devnet-6be.86067e06a5"')) | |
url=$(echo "$json_str" | jq -r '.REACT_APP_NAMADA_URL // "https://proxy.heliax.click/internal-devnet-6be.86067e06a5"')) | |
cosmos_alias=$(echo "$json_str" | jq -r '.REACT_APP_COSMOS_ALIAS // "Cosmos Testnet"') | |
cosmos_chain_id=$(echo "$json_str" | jq -r '.REACT_APP_COSMOS_CHAIN_ID // "cosmoshub-4"') | |
cosmos_chain_url=$(echo "$json_str" | jq -r '.REACT_APP_COSMOS_CHAIN_URL // "https://rpc.sentry-01.theta-testnet.polypore.xyz"') | |
osmosis_alias=$(echo "$json_str" | jq -r '.REACT_APP_OSMOSIS_ALIAS // "Osmosis Testnet"') | |
osmosis_chain_id=$(echo "$json_str" | jq -r '.REACT_APP_OSMOSIS_CHAIN_ID // "osmosis-testnet.123412341234"') | |
osmosis_url=$(echo "$json_str" | jq -r '.REACT_APP_OSMOSIS_URL // "http://127.0.0.1:54321"') | |
api_url=$(echo "$json_str" | jq -r '.REACT_APP_API_URL') | |
api_key=$(echo "$json_str" | jq -r '.REACT_APP_API_KEY') | |
api_ttl=$(echo "$json_str" | jq -r '.REACT_APP_API_TTL') | |
# Set environment variables for the workflow | |
echo "REACT_APP_NAMADA_ALIAS=$alias" >> $GITHUB_ENV | |
echo "REACT_APP_NAMADA_CHAIN_ID=$chain_id" >> $GITHUB_ENV | |
echo "REACT_APP_NAMADA_URL=$url" >> $GITHUB_ENV | |
echo "REACT_APP_COSMOS_ALIAS=$cosmos_alias" >> $GITHUB_ENV | |
echo "REACT_APP_COSMOS_CHAIN_ID=$cosmos_chain_id" >> $GITHUB_ENV | |
echo "REACT_APP_COSMOS_CHAIN_URL=$cosmos_chain_url" >> $GITHUB_ENV | |
echo "REACT_APP_OSMOSIS_ALIAS=$osmosis_alias" >> $GITHUB_ENV | |
echo "REACT_APP_OSMOSIS_CHAIN_ID=$osmosis_chain_id" >> $GITHUB_ENV | |
echo "REACT_APP_OSMOSIS_URL=$osmosis_url" >> $GITHUB_ENV | |
echo "REACT_APP_API_URL=$api_url" >> $GITHUB_ENV | |
echo "REACT_APP_API_KEY=$api_key" >> $GITHUB_ENV | |
echo "REACT_APP_API_TTL=$api_ttl" >> $GITHUB_ENV | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
working-directory: ./apps/namada-interface | |
run: yarn | |
- name: Install protoc | |
run: sudo apt-get install -y protobuf-compiler | |
- name: Install wasm-pack | |
uses: jetli/wasm-pack-action@v0.3.0 | |
with: | |
version: "v0.10.3" | |
- name: build the site | |
uses: borales/actions-yarn@v4 | |
working-directory: ./apps/namada-interface | |
run: yarn build | |
- name: Deploy to Netlify | |
uses: nwtgck/actions-netlify@v1.2.3 | |
with: | |
publish-dir: "./apps/namada-interface/build" | |
production-branch: main | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
deploy-message: "Merged PR ${{ github.event.number }} to main" | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_ACCESS_TOKEN_WALLET_PREVIEW }} | |
NETLIFY_SITE_ID: 2380782e-9b20-477a-bc27-b4e9d05e16f3 | |
- name: Slack Notification | |
run: | | |
curl --header "Content-Type: application/json" \ | |
--request POST \ | |
--data '{"message":"https://wallet-preview-heliax-dev.netlify.app"}' \ | |
${{ secrets.SLACK_WEBHOOK_WALLET_RELEASE }} | |