Skip to content

Commit

Permalink
ci: scheduled&manual workflow to update bin.walrus.site (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlegner authored Jul 19, 2024
1 parent a2050f7 commit 27b294a
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 48 deletions.
73 changes: 73 additions & 0 deletions .github/actions/set-up-walrus/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Set up Walrus and Walrus Sites
description: Install and configure Walrus and build the Walrus Sites site-builder

inputs:
SUI_ADDRESS:
description: The Sui address to use
required: true
SUI_KEYSTORE:
description: The content of the Sui keystore file
required: true

runs:
using: "composite"
steps:
- name: Create bin directory and add to $PATH
run: |
mkdir -p bin
echo "$(pwd)/bin" >> ${GITHUB_PATH}
shell: bash
- name: Define environment variables
run: |
echo "SUI_CONFIG_DIR=/home/runner/.sui/sui_config" >> $GITHUB_ENV
echo "SUI_KEYSTORE_FILE=/home/runner/.sui/sui_config/sui.keystore" >> $GITHUB_ENV
echo "SUI_CONFIG_FILE=/home/runner/.sui/sui_config/client.yaml" >> $GITHUB_ENV
echo "SUI_ADDRESS=${{ inputs.SUI_ADDRESS }}" >> $GITHUB_ENV
shell: bash

- name: Set up Sui wallet
run: |
mkdir -p $SUI_CONFIG_DIR
CLIENT_CONF="---
keystore:
File: $SUI_KEYSTORE_FILE
envs:
- alias: testnet
rpc: \"https://fullnode.testnet.sui.io:443\"
active_env: testnet
active_address: \"$SUI_ADDRESS\""
echo "$CLIENT_CONF" > $SUI_CONFIG_FILE
cat $SUI_CONFIG_FILE
echo '${{ inputs.SUI_KEYSTORE }}' > $SUI_KEYSTORE_FILE
shell: bash
- name: Get SUI from faucet
run: >
curl --location --request POST 'https://faucet.testnet.sui.io/gas'
--header 'Content-Type: application/json'
--data-raw "{
\"FixedAmountRequest\": {
\"recipient\": \"$SUI_ADDRESS\"
}
}"
shell: bash

- name: Install and configure Walrus
run: |
# The bin directory was already created and added to $PATH in the build-mdbook action
curl https://storage.googleapis.com/mysten-walrus-binaries/latest/walrus-latest-ubuntu-x86_64 -o bin/walrus
chmod +x bin/walrus
mkdir -p ~/.walrus
curl https://storage.googleapis.com/mysten-walrus-binaries/walrus-configs/client_config.yaml -o ~/.walrus/client_config.yaml
walrus -h # Ensure the walrus binary works
shell: bash

- name: Clone walrus-sites
run: git clone https://github.com/MystenLabs/walrus-sites
shell: bash
- name: Build site-builder
run: |
cd walrus-sites
cargo build --release
cp target/release/site-builder ../bin
cd -
shell: bash
53 changes: 5 additions & 48 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Build docs and publish to GitHub Pages and Walrus

on:
push:
branches:
Expand Down Expand Up @@ -51,59 +52,15 @@ jobs:
runs-on: ubuntu-ghcloud
if: ${{ github.event_name == 'push' || inputs.update-walrus-site == true }}
env:
SUI_ADDRESS: ${{ vars.SUI_ADDRESS }}
SUI_CONFIG_DIR: /home/runner/.sui/sui_config
SUI_KEYSTORE_FILE: /home/runner/.sui/sui_config/sui.keystore
SUI_CONFIG_FILE: /home/runner/.sui/sui_config/client.yaml
# Colors don't seem to work properly with the multiline commands.
NO_COLOR: 1
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-mdbook
- name: Clean docs
run: rm build/**/.nojekyll

- name: Set up Sui wallet
run: |
mkdir -p $SUI_CONFIG_DIR
CLIENT_CONF="---
keystore:
File: $SUI_KEYSTORE_FILE
envs:
- alias: testnet
rpc: \"https://fullnode.testnet.sui.io:443\"
active_env: testnet
active_address: \"$SUI_ADDRESS\""
echo "$CLIENT_CONF" > $SUI_CONFIG_FILE
cat $SUI_CONFIG_FILE
echo '${{ secrets.SUI_KEYSTORE }}' > $SUI_KEYSTORE_FILE
- name: Get SUI from faucet
run: >
curl --location --request POST 'https://faucet.testnet.sui.io/gas'
--header 'Content-Type: application/json'
--data-raw "{
\"FixedAmountRequest\": {
\"recipient\": \"$SUI_ADDRESS\"
}
}"
- name: Install and configure Walrus
run: |
# The bin directory was already created and added to $PATH in the build-mdbook action
curl https://storage.googleapis.com/mysten-walrus-binaries/latest/walrus-latest-ubuntu-x86_64 -o bin/walrus
chmod +x bin/walrus
mkdir -p ~/.walrus
curl https://storage.googleapis.com/mysten-walrus-binaries/walrus-configs/client_config.yaml -o ~/.walrus/client_config.yaml
walrus -h # Ensure the walrus binary works
- name: Clone walrus-sites
run: git clone https://github.com/MystenLabs/walrus-sites
- name: Build site-builder
run: |
cd walrus-sites
cargo build --release
cp target/release/site-builder ../bin
cd -
- uses: ./.github/actions/set-up-walrus
with:
SUI_ADDRESS: "${{ vars.SUI_ADDRESS }}"
SUI_KEYSTORE: "${{ secrets.SUI_KEYSTORE }}"

- name: Update Walrus Site
run: >
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/update-binaries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Update bin.walrus.site with latest binaries

on:
# every week
schedule:
- cron: '14 3 * * 0'
# on demand
workflow_dispatch:

concurrency: ci-${{ github.ref }}

permissions:
contents: read

jobs:
# We store the data for the Sui wallet and the site object in GitHub variables
# (https://github.com/MystenLabs/walrus-docs/settings/variables/actions) and secrets
# (https://github.com/MystenLabs/walrus-docs/settings/secrets/actions).
update-bin-walrus-site:
name: Update Walrus Site bin.walrus.site
runs-on: ubuntu-ghcloud
env:
# Colors don't seem to work properly with the multiline commands.
NO_COLOR: 1
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/set-up-walrus
with:
SUI_ADDRESS: "${{ vars.SUI_ADDRESS }}"
SUI_KEYSTORE: "${{ secrets.SUI_KEYSTORE }}"

- name: Create temporary directory
run: "mkdir -p site"
- name: Download latest binaries
run: |
for arch in ubuntu-x86_64 macos-x86_64 macos-arm64; do
curl https://storage.googleapis.com/mysten-walrus-binaries/latest/walrus-latest-$arch -o site/walrus-$arch
done
- name: Copy site-builder binary
run: "cp bin/site-builder site/site-builder-ubuntu-x86_64"

- name: Update Walrus Site
run: >
RUST_LOG=site_builder=debug,walrus=debug,info
site-builder
--config walrus-sites/site-builder/assets/builder-example.yaml
update --list-directory site ${{ vars.WALRUS_SITE_BIN_OBJECT }}

0 comments on commit 27b294a

Please sign in to comment.