adding gh workflow for v1 -> v2 migration (#2127)

* adding gh workflow for v1 -> v2 migration

* add md5 verify script

* Use GH_TOKEN instead of GITHUB_TOKEN

* add workflow dispatch

* Update chainstate dir location

* mkdir for CHAINSTATE_DIR
This commit is contained in:
Charlie
2020-12-09 10:09:23 -05:00
committed by GitHub
parent 1ad60a216e
commit 68958ae3ad
3 changed files with 83 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ on:
release:
types:
- published
workflow_dispatch:
jobs:
run:

View File

@@ -166,7 +166,9 @@ jobs:
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Use custom secrets.GH_TOKEN instead of default secrets.GITHUB_TOKEN because the custom token will trigger the
# clarity-js-sdk-pr workflow. As events caused by default tokens do not trigger subsequent workflow runs to avoid loops.
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
tag_name: ${{ github.event.inputs.tag || github.ref }}
release_name: Release ${{ github.event.inputs.tag || github.ref }}

79
.github/workflows/v1-v2-migration.yml vendored Normal file
View File

@@ -0,0 +1,79 @@
##
## This workflow is used to help facilitate the V1 -> V2 migration.
## It pulls down the latest V1 export, commits the new chainstate file to a feature branch,
## and opens a PR against the master branch.
##
name: V1 to V2 Migration
env:
COMMIT_USER: Hiro DevOps
COMMIT_EMAIL: 45208873+blockstack-devops@users.noreply.github.com
UPDATE_BRANCH: auto/v1-v2-migration
CHAINSTATE_DIR: stx-genesis
CHAINSTATE_URL: https://storage.googleapis.com/blockstack-v1-migration-data/chainstate.txt
CHAINSTATE_METADATA_URL: https://storage.googleapis.com/storage/v1/b/blockstack-v1-migration-data/o/chainstate.txt
CHAINSTATE_HASH_URL: https://storage.googleapis.com/blockstack-v1-migration-data/chainstate.txt.sha256
CHAINSTATE_HASH_METADATA_URL: https://storage.googleapis.com/storage/v1/b/blockstack-v1-migration-data/o/chainstate.txt.sha256
MD5_VERIFY_SCRIPT_URL: https://gist.github.com/wileyj/93b4222576cb702053ebfcd3cf9f570b
on:
repository_dispatch:
types:
- migration
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout stacks-blockchain
uses: actions/checkout@v2
with:
token: ${{ secrets.GH_TOKEN }}
ref: master
- name: Update files
run: |
mkdir -p ${CHAINSTATE_DIR}
curl -s ${CHAINSTATE_URL} > ${CHAINSTATE_DIR}/chainstate.txt
echo "CHAINSTATE_TIME_CREATED=$(curl -s ${CHAINSTATE_METADATA_URL} | jq -r '.timeCreated')" >> $GITHUB_ENV
echo "CHAINSTATE_SIZE=$(curl -s ${CHAINSTATE_METADATA_URL} | jq -r '.size')" >> $GITHUB_ENV
echo "CHAINSTATE_MD5=$(curl -s ${CHAINSTATE_METADATA_URL} | jq -r '.md5Hash')" >> $GITHUB_ENV
echo "CHAINSTATE_DOWNLOAD_LINK=$(curl -s ${CHAINSTATE_METADATA_URL} | jq -r '.mediaLink')" >> $GITHUB_ENV
curl -s ${CHAINSTATE_HASH_URL} > ${CHAINSTATE_DIR}/chainstate.txt.sha256
echo "CHAINSTATE_HASH_TIME_CREATED=$(curl -s ${CHAINSTATE_HASH_METADATA_URL} | jq -r '.timeCreated')" >> $GITHUB_ENV
echo "CHAINSTATE_HASH_SIZE=$(curl -s ${CHAINSTATE_HASH_METADATA_URL} | jq -r '.size')" >> $GITHUB_ENV
echo "CHAINSTATE_HASH_MD5=$(curl -s ${CHAINSTATE_HASH_METADATA_URL} | jq -r '.md5Hash')" >> $GITHUB_ENV
echo "CHAINSTATE_HASH_DOWNLOAD_LINK=$(curl -s ${CHAINSTATE_HASH_METADATA_URL} | jq -r '.mediaLink')" >> $GITHUB_ENV
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GH_TOKEN }}
commit-message: Update v2 chainstate files
committer: ${{ env.COMMIT_USER }} <${{ env.COMMIT_EMAIL }}>
author: ${{ env.COMMIT_USER }} <${{ env.COMMIT_EMAIL }}>
branch: ${{ env.UPDATE_BRANCH }}
title: "[Stacks v1 → v2 Upgrade] Final update to chainstate files"
body: |
:robot: This is an automated pull request created from reaching the threshold of BNS names registered under the `.miner` namespace.
This PR updates the chainstate and chainstate consensus hash files to be used in the creation of the genesis block in the Stacks V2 network:
* [chainstate.txt](${{ env.CHAINSTATE_URL }})
* Time created: `${{ env.CHAINSTATE_TIME_CREATED }}`
* File size: `${{ env.CHAINSTATE_SIZE }} bytes`
* MD5 Hash: `${{ env.CHAINSTATE_MD5 }}`
* [Verify the MD5 hash with this script](${{ env.MD5_VERIFY_SCRIPT_URL }})
* [Download file](${{ env.CHAINSTATE_DOWNLOAD_LINK }})
* [chainstate.txt.sha256](${{ env.CHAINSTATE_HASH_URL }})
* Time created: `${{ env.CHAINSTATE_HASH_TIME_CREATED }}`
* File size: `${{ env.CHAINSTATE_HASH_SIZE }} bytes`
* MD5 Hash: `${{ env.CHAINSTATE_HASH_MD5 }}`
* [Verify the MD5 hash with this script](${{ env.MD5_VERIFY_SCRIPT_URL }})
* [Download file](${{ env.CHAINSTATE_HASH_DOWNLOAD_LINK }})
Once merged, a new tag will need to be created. This can be done one of two ways:
* Trigger this [Github workflow](https://github.com/blockstack/stacks-blockchain/actions?query=workflow%3Astacks-blockchain) from the `master` branch by selecting "Run Workflow", passing in the desired tag to be created as an argument
* Create the new tag from the `master` branch locally and push it up
assignees: jcnelson,kantai,lgalabru,diwakergupta
reviewers: CharlieC3,wileyj,zone117x,jcnelson,kantai,lgalabru,diwakergupta