Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added dev chains CI #148

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/deploy_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Deploy

on:
pull_request:

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: 🛎 Checkout
id: checkout
uses: actions/checkout@v3

- uses: ./.github/workflows/rust-install

- name: ⚙ Run verifier
id: verify
run: make verifier

- name: ⚙ Run collector
id: collect
run: |
cargo run --release -- -c=config.toml collect
exit_code=$?
if [ $exit_code -eq 12 ]
then
echo "::set-output name=redeploy::true"
exit 0
fi
echo "::set-output name=redeploy::false"
exit $exit_code
shell: bash {0}

- name: ⚙ Run collector dev
id: collect
run: |
cargo run --release -- -c=config_dev.toml collect
exit_code=$?
if [ $exit_code -eq 12 ]
then
echo "::set-output name=redeploy::true"
exit 0
fi
echo "::set-output name=redeploy::false"
exit $exit_code
shell: bash {0}

- uses: ./.github/workflows/deploy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like it is the same action as for the main deployment
Isn't this version going to overlay the main version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the action is the same. It just builds the NPM package and updates the gh-pages. NPM is the same for dev and prod builds.
Thank you for noticing it. I missed it and it may cause a big problem. Lucky that deploy isn't environment dependent.

id: deploy
if: success() || failure() && (steps.collect.outcome == 'failure')
with:
token: ${{ secrets.GITHUB_TOKEN }}
147 changes: 147 additions & 0 deletions .github/workflows/update-and-sign-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Check updates&sign for dev chains

on:
workflow_dispatch:

env:
BRANCH_PREFIX: updated-codes
NOTIFY_MATRIX: false
NOTIFY_TELEGRAM: true
GITHUB_WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
pgolovkin marked this conversation as resolved.
Show resolved Hide resolved

jobs:
update:
runs-on: ubuntu-latest
steps:
- name: 🛎 Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: 🔧 Install rust dependencies
uses: ./.github/workflows/rust-install

- name: Try to checkout exising PR branch
id: checkout-pr
run: |
SIGN_ME_BRANCH=$(git branch -r --list "origin/$BRANCH_PREFIX-*" --sort=-refname | head -n 1)
if [ -z "$SIGN_ME_BRANCH" ]
then
switched="false"
else
git checkout --track $SIGN_ME_BRANCH
switched="true"
fi
echo "::set-output name=switched::$switched"

- name: ⚙ Build metadata-cli
uses: actions-rs/cargo@v1
with:
command: build
args: --release

- name: ⚙ Update QRs from RPC nodes
id: update-nodes
run: |
cargo run --release -- -c=config_dev.toml update --sign --signing-key ${{secrets.SIGNING_KEY}} --source node
exit_code=$?
if [ $exit_code -eq 12 ]
then
echo "::set-output name=chainsSkipped::true"
exit 0
fi
echo "::set-output name=chainsSkipped::false"
exit $exit_code
shell: bash {0}

- name: ⚙ Update QRs from GitHub releases
run: |
cargo run --release -- -c=config_dev.toml update --sign --signing-key ${{secrets.SIGNING_KEY}} --source github

- name: ⚙ Run collector
id: collect
run: |
cargo run --release -- -c=config_dev.toml collect
exit_code=$?
if [ $exit_code -eq 12 ]
then
echo "::set-output name=chainsSkipped::true"
exit 0
fi
echo "::set-output name=chainsSkipped::false"
exit $exit_code
shell: bash {0}

- name: ⚙ Run cleaner
if: ${{ steps.collect.outputs.chainsSkipped == 'false' }}
id: cleaner
run: cargo run --release -- -c=config_dev.toml clean

- name: 📌 Commit changes if PR exists
if: ${{ steps.checkout-pr.outputs.switched == 'true' }}
uses: ./.github/workflows/commit-changes
with:
message: 'metadata update&sign'

- name: New PR branch
if: ${{ steps.checkout-pr.outputs.switched == 'false' }}
id: new-branch
run: |
NAME="$BRANCH_PREFIX-$(date '+%Y-%m-%d')"
echo "::set-output name=name::$NAME"

- name: Create Pull Request if not exist
if: ${{ steps.checkout-pr.outputs.switched == 'false' }}
id: cpr
uses: peter-evans/create-pull-request@f22a7da129c901513876a2380e2dae9f8e145330
with:
commit-message: add updated QR codes
branch: ${{ steps.new-branch.outputs.name }}
delete-branch: true
base: master
title: '[Automated] Review new metadata QRs'
body: |
Updated metadata QR codes
reviewers: "stepanLav,pgolovkin,tuul-wq,Asmadek"
draft: false

check-deployment:
runs-on: ubuntu-latest
steps:
- name: 🛎 Checkout
uses: actions/checkout@v3

- name: 🔧 Install rust dependencies
uses: ./.github/workflows/rust-install

- name: ⚙ Check existing deployment
id: check-deployment
run: |
cargo run --release -- -c=config_dev.toml check-deployment
exit_code=$?
if [ $exit_code -eq 12 ]
then
echo "::set-output name=redeploy::true"
exit 0
fi
echo "::set-output name=redeploy::false"
exit $exit_code
shell: bash {0}

- name: ⚙ Run collector
id: collect
if: ${{ steps.check-deployment.outputs.redeploy == 'true' }}
run: |
cargo run --release -- -c=config_dev.toml collect
exit_code=$?
if [ $exit_code -eq 12 ]
then
exit 0
fi
exit $exit_code
shell: bash {0}

- if: ${{ steps.check-deployment.outputs.redeploy == 'true' }}
uses: ./.github/workflows/deploy
with:
token: ${{ secrets.GITHUB_TOKEN }}