refactor: Improve types for baseAttributes/attributes #974
Workflow file for this run
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: 'Deploy: Cloudflare PR Preview' | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize, ready_for_review] | |
env: | |
PAGES_PROJECT_NAME: optimizer | |
PAGES_PROJECT_URL_SLUG: discretize-gear-optimizer | |
NODE_VERSION: 18 | |
jobs: | |
# see https://github.com/orgs/community/discussions/26726, https://stackoverflow.com/a/70249520 | |
check-secrets: | |
runs-on: ubuntu-latest | |
outputs: | |
exists: ${{ steps.check-secret-step.outputs.exists }} | |
steps: | |
- name: Check that secrets exist | |
id: check-secret-step | |
run: | | |
if [ "${{ secrets.CI_CF_PAGES }}" != '' ]; then | |
echo "exists=true" >> $GITHUB_OUTPUT; | |
else | |
echo "exists=false" >> $GITHUB_OUTPUT; | |
fi | |
deployment: | |
needs: [check-secrets] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
deployments: write | |
pull-requests: write | |
if: > | |
needs.check-secrets.outputs.exists == 'true' && | |
github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name && | |
!contains(github.event.head_commit.message, 'skip ci') && | |
!contains(github.event.pull_request.body, '[no previews]') && | |
(contains(github.event.pull_request.body, '[draft previews]') || github.event.pull_request.draft == false) | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up PNPM | |
uses: pnpm/action-setup@v4 | |
- name: Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: pnpm | |
- name: Install dependencies | |
run: pnpm install | |
- name: Cache Rust Output | |
id: rust-output-cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
wasm_module/pkg | |
wasm_module/target | |
key: rust-output-${{ env.NODE_VERSION }}-${{ hashFiles('wasm_module', '**/pnpm-lock.yaml') }} | |
restore-keys: rust-output- | |
- name: Cache Rust Dependencies | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: wasm_module | |
if: steps.rust-output-cache.outputs.cache-hit != 'true' | |
- name: Compile Rust | |
run: pnpm wasm | |
if: steps.rust-output-cache.outputs.cache-hit != 'true' | |
- name: Build Cloudflare | |
run: pnpm build-cf | |
- name: Deploy preview to Cloudflare | |
uses: cloudflare/pages-action@1 | |
id: pages-action | |
with: | |
apiToken: ${{ secrets.CI_CF_PAGES }} | |
accountId: ${{ secrets.CF_ACCOUNT_ID }} | |
projectName: ${{ env.PAGES_PROJECT_NAME }} | |
directory: dist | |
branch: ${{ github.head_ref || github.ref_name }} | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
wranglerVersion: '3' | |
- name: Comment PR | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
message: | | |
Deployed ${{ steps.pages-action.outputs.environment }} build to Cloudflare! | |
| | | | |
| ----------------------- | - | | |
| **Last commit:** | ${{ github.event.pull_request.head.sha || github.event.workflow_run.head_sha || github.sha }} | | |
| **Preview URL**: | ${{ steps.pages-action.outputs.url }} | | |
| **Branch Preview URL**: | https://${{ github.head_ref || github.ref_name }}.${{ env.PAGES_PROJECT_URL_SLUG }}.pages.dev | | |
comment_tag: deployment | |
mode: upsert |