feat: allow canister_info to be invoked via query calls #456
Workflow file for this run
This file contains hidden or 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: | |
| # Needs repo secrets and write access to post the preview comment, so skip | |
| # any PR whose runs get a read-only token: forks and Dependabot. Those are | |
| # covered by build.yml instead. | |
| if: >- | |
| github.event.pull_request.head.repo.full_name == github.repository && | |
| github.event.pull_request.user.login != 'dependabot[bot]' | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: pr-${{ github.event.pull_request.number || github.event.number }} | |
| cancel-in-progress: true | |
| steps: | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| - name: Initialize submodules | |
| run: | | |
| git config --global url."https://github.com/".insteadOf "git@github.com:" | |
| git submodule update --init --depth 1 .sources/examples .sources/motoko | |
| - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 | |
| with: | |
| script: | | |
| const comments = require('./.github/workflows/scripts/comments.cjs'); | |
| 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@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4.9.1 | |
| with: | |
| python-version: "3.10" | |
| - name: Install icp-cli | |
| run: npm i -g @icp-sdk/icp-cli@1.2.0 @icp-sdk/ic-wasm | |
| - run: npm ci | |
| - name: Build & Deploy | |
| run: | | |
| # Setup identity | |
| mkdir -p ~/.local/share/icp-cli/identity/keys | |
| echo $POOL_CONTROLLER_IDENTITY | base64 -d > ~/.local/share/icp-cli/identity/keys/preview-deploy.pem | |
| sed -i 's/\\r\\n/\r\n/g' ~/.local/share/icp-cli/identity/keys/preview-deploy.pem | |
| icp identity import preview-deploy --from-pem ~/.local/share/icp-cli/identity/keys/preview-deploy.pem --storage plaintext | |
| icp identity default preview-deploy | |
| # Request preview canister from the pool | |
| pip install icp-py-core "cbor2<6" | |
| canister_id=$(python3 .github/workflows/scripts/request-canister.py ${{ github.event.pull_request.number }}) | |
| # Override canister ID mapping for ic environment | |
| echo "{\"frontend\":\"$canister_id\"}" > .icp/data/mappings/ic.ids.json | |
| echo "PREVIEW_CANISTER_ID=$canister_id" >> $GITHUB_ENV | |
| # Deploy (icp.yaml recipe handles the build) | |
| ICP_CLI_PLUGIN_COMPUTE_LIMIT_SECS=120 icp deploy frontend -e ic --mode reinstall | |
| env: | |
| POOL_CONTROLLER_IDENTITY: ${{ secrets.POOL_CONTROLLER_IDENTITY }} | |
| POOL_CANISTER_ID: ${{ secrets.POOL_CANISTER_ID }} | |
| - name: Report build error | |
| uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 | |
| if: ${{ failure() }} | |
| with: | |
| script: | | |
| const comments = require('./.github/workflows/scripts/comments.cjs'); | |
| 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@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 | |
| with: | |
| script: | | |
| const comments = require('./.github/workflows/scripts/comments.cjs'); | |
| 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`); | |
| } |