Check updates #773
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 | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 */6 * * *' | |
env: | |
BRANCH_PREFIX: sign-me | |
NOTIFY_MATRIX: false | |
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 "switched=$switched" >> $GITHUB_OUTPUT | |
- name: ⚙ Build metadata-cli | |
run: cargo build --release | |
- name: ⚙ Update QRs from RPC nodes | |
run: cargo run --release -- update --source node | |
#- name: ⚙ Update QRs from GitHub releases | |
# run: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} cargo run --release -- update --source github | |
- name: 📌 Commit changes if PR exists | |
if: ${{ steps.checkout-pr.outputs.switched == 'true' }} | |
uses: ./.github/workflows/commit-changes | |
with: | |
message: 'metadata update' | |
- name: New PR branch | |
if: ${{ steps.checkout-pr.outputs.switched == 'false' }} | |
id: new-branch | |
run: | | |
NAME="$BRANCH_PREFIX-$(date '+%Y-%m-%d')" | |
echo "name=$NAME" >> $GITHUB_OUTPUT | |
- name: Create Pull Request if not exist | |
if: ${{ steps.checkout-pr.outputs.switched == 'false' }} | |
id: cpr | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
commit-message: add unsigned QR codes | |
branch: ${{ steps.new-branch.outputs.name }} | |
delete-branch: true | |
base: master | |
title: '[Automated] Sign new metadata QRs' | |
body: | | |
Checkout this branch locally and run: | |
- [ ] `make signer` to sign files | |
- [ ] `make collector` to gather information about current chain versions | |
- [ ] `make cleaner` to remove obsolete QRs | |
draft: true | |
- name: Notify Matrix channel | |
uses: s3krit/[email protected] | |
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! 📑 | |
[GitHub PR#${{ steps.cpr.outputs.pull-request-number }}](${{ steps.cpr.outputs.pull-request-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 "redeploy=true" >> $GITHUB_OUTPUT | |
exit 0 | |
fi | |
echo "redeploy=false" >> $GITHUB_OUTPUT | |
exit $exit_code | |
shell: bash {0} | |
- name: ⚙ Run collector | |
if: ${{ steps.check-deployment.outputs.redeploy == 'true' }} | |
run: make collector | |
- if: ${{ steps.check-deployment.outputs.redeploy == 'true' }} | |
uses: ./.github/workflows/deploy | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} |