diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml new file mode 100644 index 000000000..4429ec441 --- /dev/null +++ b/.github/workflows/deploy_dev.yml @@ -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 + id: deploy + if: success() || failure() && (steps.collect.outcome == 'failure') + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-and-sign-dev.yml b/.github/workflows/update-and-sign-dev.yml new file mode 100644 index 000000000..51b3eca6d --- /dev/null +++ b/.github/workflows/update-and-sign-dev.yml @@ -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 }} + +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 }}