This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
[FINAL] feat: allow canister http outcalls to specify transform of another canister #644
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: 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@v4 | |
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 | tr -d '\n\r ' | base64 -d > ~/.config/dfx/identity/default/identity.pem | |
sed -i 's/\\r\\n/\r\n/g' ~/.config/dfx/identity/default/identity.pem | |
# 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) | |
# this is where the root of the web pages resides | |
cd docusaurus | |
# 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 | |
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 }} | |
- 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/docs`); | |
} else { | |
await comments.create(context, github, `🤖 Here's your preview: https://${process.env.PREVIEW_CANISTER_ID}.icp0.io/docs`); | |
} |