Check updates&sign #8450
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: Check updates&sign | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 */2 * * *' | |
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.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 update --sign --signing-key ${{secrets.SIGNING_KEY}} --source github | |
- name: β Run collector | |
id: collect | |
run: | | |
cargo run --release 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: π 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 | |
- name: Notify Matrix channel | |
uses: s3krit/matrix-message-action@v0.0.3 | |
if: ${{ env.NOTIFY_MATRIX == 'true' && steps.cpr.outputs.pull-request-operation == 'created' }} | |
with: | |
room_id: ${{ secrets.MATRIX_ROOM_ID }} | |
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }} | |
server: ${{ secrets.MATRIX_SERVER }} | |
message: "# New metadata is available and signed! π [GitHub PR#${{ steps.cpr.outputs.pull-request-number }}](${{ steps.cpr.outputs.pull-request-url }})" | |
- name: Notify Telegram channel | |
uses: appleboy/telegram-action@master | |
if: ${{ env.NOTIFY_TELEGRAM == 'true' && steps.cpr.outputs.pull-request-operation == 'created' }} | |
with: | |
to: ${{ secrets.TELEGRAM_TO }} | |
token: ${{ secrets.TELEGRAM_TOKEN }} | |
message: | | |
New metadata is available and signed! π | |
${{ steps.cpr.outputs.pull-request-url }} | |
- name: Send error to Matrix channel | |
uses: s3krit/matrix-message-action@v0.0.3 | |
if: ${{ failure() && env.NOTIFY_MATRIX == 'true' }} | |
with: | |
room_id: ${{ secrets.MATRIX_ROOM_ID }} | |
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }} | |
server: ${{ secrets.MATRIX_SERVER }} | |
message: "βοΈ Error updating metadata! β ${{ env.GITHUB_WORKFLOW_URL }}" | |
- name: Send error to Telegram channel | |
uses: appleboy/telegram-action@master | |
if: ${{ failure() && env.NOTIFY_TELEGRAM == 'true' }} | |
with: | |
to: ${{ secrets.TELEGRAM_TO }} | |
token: ${{ secrets.TELEGRAM_TOKEN }} | |
message: | | |
βοΈ Error updating metadata! β | |
${{ env.GITHUB_WORKFLOW_URL }} | |
- name: Send update warning to Matrix channel | |
uses: s3krit/matrix-message-action@v0.0.3 | |
if: ${{ steps.update-nodes.outputs.chainsSkipped == 'true' && env.NOTIFY_MATRIX == 'true'}} | |
with: | |
room_id: ${{ secrets.MATRIX_ROOM_ID }} | |
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }} | |
server: ${{ secrets.MATRIX_SERVER }} | |
message: "β οΈ Some networks were not available! Please, check the log! β οΈ ${{ env.GITHUB_WORKFLOW_URL }}" | |
- name: Send update warning to Telegram channel | |
uses: appleboy/telegram-action@master | |
if: ${{ steps.update-nodes.outputs.chainsSkipped == 'true' && env.NOTIFY_TELEGRAM == 'true'}} | |
with: | |
to: ${{ secrets.TELEGRAM_TO }} | |
token: ${{ secrets.TELEGRAM_TOKEN }} | |
message: "β οΈ Some networks were not available! Please, check the log! β οΈ ${{ env.GITHUB_WORKFLOW_URL }}" | |
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 -- 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.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 }} |