Skip to content

fix: Page title and sidebar order #6500

fix: Page title and sidebar order

fix: Page title and sidebar order #6500

name: PR Preview Deployment
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
build_and_deploy:
# do not run in forks
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/github-script@v6
with:
script: |
const comments = require('./.github/workflows/scripts/comments.js');
const maybeComment = await comments.get(context, github);
if (maybeComment) {
await comments.update(context, github, maybeComment.id, `🤖 Your PR preview is being built...`);
} else {
await comments.create(context, github, `🤖 Your PR preview is being built...`);
}
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install DFX
uses: dfinity/setup-dfx@main
- name: "Build & Deploy"
run: |
mkdir -p ~/.config/dfx/identity/default
echo $DFX_IDENTITY_PREVIEW | base64 -d > ~/.config/dfx/identity/default/identity.pem
sed -i 's/\\r\\n/\r\n/g' ~/.config/dfx/identity/default/identity.pem
# check pool canister balance and send notification if it's under 5TC
balance=$(dfx canister --network ic status $POOL_CANISTER_ID 2>&1 >/dev/null | grep Balance: | sed 's/[^0-9]//g')
LANG=en_US.UTF-8
balance_formatted=$(echo $balance | awk '{printf "%'\''d\n", $0}')
echo "Pool balance: $balance_formatted"
if [ "5000000000000" -gt "$balance" ]; then
template="{ \"channel\": \"C04EGHHU9U2\", \"blocks\": [ { \"type\": \"section\", \"text\": { \"type\": \"mrkdwn\", \"text\": \"@channel Preview pool canister \`$POOL_CANISTER_ID\` balance is \`$balance_formatted\`.\n\nTop it up by\n- running \`dfx ledger --network ic top-up $POOL_CANISTER_ID --amount 5.0\`\n- or by adding the canister on the NNS and sending cycles to it.\" } } ]}"
curl --data "$template" -H "Content-type: application/json" -H "Authorization: Bearer $SLACK_TOKEN" -X POST https://slack.com/api/chat.postMessage -o /dev/null
fi
# request preview canister from the pool
pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
pip install ic-py
canister_id=$(python3 .github/workflows/scripts/request-canister.py $pull_number)
# overwrite canister id in dfx.json
echo "{\"portal\":{\"ic\":\"$canister_id\"}}" > canister_ids.json
echo "PREVIEW_CANISTER_ID=$canister_id" >> $GITHUB_ENV
# install and deploy
git submodule update --init
npm install
export PREVIEW_CANISTER_ID=$canister_id
dfx deploy --network=ic --no-wallet portal --yes
env:
DFX_IDENTITY_PREVIEW: ${{ secrets.DFX_IDENTITY_PREVIEW }}
POOL_CANISTER_ID: ${{ secrets.POOL_CANISTER_ID }}
CONTENTFUL_ACCESS_TOKEN: ${{ secrets.CONTENTFUL_ACCESS_TOKEN }}
CONTENTFUL_HOST: ${{ secrets.CONTENTFUL_HOST }}
CONTENTFUL_SPACE_ID: ${{ secrets.CONTENTFUL_SPACE_ID }}
AIRTABLE_KEY: ${{ secrets.AIRTABLE_SA_PORTAL_SERVICE_ACCOUNT }}
YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
- name: Report build error
uses: actions/github-script@v6
if: ${{ failure() }}
with:
script: |
const comments = require('./.github/workflows/scripts/comments.js');
const maybeComment = await comments.get(context, github);
if (maybeComment) {
await comments.update(context, github, maybeComment.id, `🤖 Preview build failed.`);
} else {
await comments.create(context, github, `🤖 Preview build failed.`);
}
- uses: actions/github-script@v6
with:
script: |
const comments = require('./.github/workflows/scripts/comments.js');
const maybeComment = await comments.get(context, github);
if (maybeComment) {
await comments.update(context, github, maybeComment.id, `🤖 Here's your preview: https://${process.env.PREVIEW_CANISTER_ID}.icp0.io`);
} else {
await comments.create(context, github, `🤖 Here's your preview: https://${process.env.PREVIEW_CANISTER_ID}.icp0.io`);
}