Skip to content
# A GitHub Actions workflow that regularly checks for a new SNS aggregator
# and creates a PR when it finds one.
name: Update aggregator
on:
schedule:
# check for new versions weekly
- cron: '30 3 * * SAT'
workflow_dispatch:
# Provide an option to run this manually.
push:
branches:
# Development branch for this workflow:
- "update-aggregator"
concurrency:
group: ${{ github.workflow }}
env:
BRANCH_NAME: 'bot-aggregator-update'
jobs:
update-dfx:
runs-on: ubuntu-latest
steps:
- name: Existing PR
id: existing_pr
run: |
echo number="$(gh pr --repo dfinity/snsdemo list --base main --head "$BRANCH_NAME" --json number --jq '.[].number')" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}
- uses: actions/checkout@v3
if: ${{ steps.existing_pr.outputs.number == '' }}
- name: Install tools
run: bin/dfx-software-more-install
if: ${{ steps.existing_pr.outputs.number == '' }}
- name: Look for new aggregator
if: ${{ steps.existing_pr.outputs.number == '' }}
id: update
run: |
. bin/versions.bash
current_version="$SNS_AGGREGATOR_RELEASE"
echo "Current SNS aggregator version: '$current_version'"
latest_version="$(./bin/dfx-software-sns-aggregator-version --latest)"
echo "Latest SNS aggregator version: '$latest_version'"
if [ "$current_version" != "$latest_version" ]
then
# Update the SNS_AGGREGATOR_RELEASE in versions.bash:
awk -v version="$latest_version" -F= 'BEGIN{IFS=OFS="="}($1=="SNS_AGGREGATOR_RELEASE"){$2=version}{print}' bin/versions.bash | sponge bin/versions.bash
echo "An update is available: $current_version -> $latest_version"
echo "updated=1" >> "$GITHUB_OUTPUT"
echo "version=$latest_version" >> "$GITHUB_OUTPUT"
else
echo "updated=0" >> "$GITHUB_OUTPUT"
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Create Pull Request
# If a newer version is available, create a PR.
if: ${{ (steps.update.outputs.updated == '1') == (steps.existing_pr.outputs.number == '') }}
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GIX_SNSDEMO_BOT_GH_TOKEN }}
base: main
add-paths: |
bin/versions.bash
commit-message: Update SNS Aggregator version
committer: GitHub <noreply@github.com>
author: gix-bot <gix-bot@users.noreply.github.com>
branch: ${{ env.BRANCH_NAME }}
delete-branch: true
title: 'Update SNS aggregator version to ${{ steps.update.outputs.version }}'
body: |
# Motivation
A new version of the SNS aggregator is available. We would like to keep the snapshots up to date.
# Changes
* Updated the pinned default SNS aggregator version.
# Tests
- Please see CI.
- name: Notify Slack on failure
# Since the this is a scheduled job, a failure won't be shown on any
# PR status. To notify the team, we send a message to our Slack channel on failure.
uses: dfinity/internet-identity/.github/actions/slack@release-2023-08-28
if: ${{ failure() }}
with:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
MESSAGE: "SNS aggregator update failed"