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: Build code in production when there is merge in main | |
on: | |
push: | |
branches: [ main ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build and Publish | |
runs-on: ubuntu-latest | |
environment: production | |
env: | |
CURRENCIES_DEVNET_FILE_NAME: "currencies_devnet.json" | |
CURRENCIES_TESTNET_FILE_NAME: "currencies_testnet.json" | |
CURRENCIES_MAINNET_FILE_NAME: "currencies_mainnet.json" | |
strategy: | |
matrix: | |
node-version: [16.x] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: 'https://registry.npmjs.org' | |
- name: Clear cache | |
run: yarn cache clean | |
- name: Install dependencies | |
run: yarn install | |
- name: Download currencies data | |
run: | | |
sudo apt-get install curl -y | |
curl "https://raw.githubusercontent.com/nolus-protocol/nolus-networks/main/devnet/vitosha-3/currencies.json" -o "$CURRENCIES_DEVNET_FILE_NAME" | |
curl "https://raw.githubusercontent.com/nolus-protocol/nolus-networks/main/testnet/rila-3/currencies.json" -o "$CURRENCIES_TESTNET_FILE_NAME" | |
curl "https://raw.githubusercontent.com/nolus-protocol/nolus-networks/main/mainnet/pirin-1/currencies.json" -o "$CURRENCIES_MAINNET_FILE_NAME" | |
- name: Build module | |
run: yarn build | |
- name: Copy LICENSE | |
run: cp LICENSE.txt build/LICENSE.txt | |
- name: Copy README | |
run: cp README.md build/README.md | |
- name: Copy package.json | |
run: cp package.json build/package.json | |
- name: Copy currencies-devnet data file | |
run: cp "$CURRENCIES_DEVNET_FILE_NAME" build/build/utils/"$CURRENCIES_DEVNET_FILE_NAME" | |
- name: Copy currencies-testnet data file | |
run: cp "$CURRENCIES_TESTNET_FILE_NAME" build/build/utils/"$CURRENCIES_TESTNET_FILE_NAME" | |
- name: Copy currencies-mainnet data file | |
run: cp "$CURRENCIES_MAINNET_FILE_NAME" build/build/utils/"$CURRENCIES_MAINNET_FILE_NAME" | |
- name: Publish package to NPM | |
run: npm publish ./build | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} |