Skip to content

Add Remix CLI

Add Remix CLI #1903

Workflow file for this run

# Create "installable" preview branches
#
# Commits to `main` push builds to a `preview/main` branch:
# pnpm install "remix-run/remix#preview/main&path:packages/remix"
#
# Pull Requests create `preview/pr-{number}` branches:
# pnpm install "remix-run/remix#preview/pr-12345&path:packages/remix"
#
# Can also be dispatched manually with base/installable branches to provide
# `experimental` branches from PRs or otherwise.
name: Preview Build
on:
push:
branches:
- main
workflow_dispatch:
inputs:
baseBranch:
description: Base Branch
required: true
installableBranch:
description: Installable Branch
required: true
pull_request:
types: [opened, synchronize, reopened, closed]
concurrency:
# Include `event_name` here because when a pull_request is merged (closed), the
# `github.ref` goes back to `ref/heads/main` which will conflict with the run on
# `main` from the merged PR
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
jobs:
preview:
# Don't run on PRs from forked repos
if: github.repository == 'remix-run/remix' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ubuntu-latest
steps:
- name: Checkout (push)
if: github.event_name == 'push'
uses: actions/checkout@v6
- name: Checkout (pull_request)
if: github.event_name == 'pull_request'
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Checkout (workflow_dispatch)
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v6
with:
ref: ${{ inputs.baseBranch }}
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Install Node.js
uses: actions/setup-node@v6
with:
node-version-file: 'package.json'
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Setup git
run: |
git config --local user.email "hello@remix.run"
git config --local user.name "Remix Run Bot"
# Build and force push over the preview/main branch
- name: Build/push branch (push)
if: github.event_name == 'push'
run: |
pnpm run setup-installable-branch preview/main
git push --force --set-upstream origin preview/main
echo "💿 pushed installable branch: https://github.com/$GITHUB_REPOSITORY/commit/$(git rev-parse HEAD)"
# Build and force push over the PR preview/pr-{number} branch + comment on the PR
- name: Build/push branch (pull_request)
if: github.event_name == 'pull_request' && github.event.pull_request.state == 'open'
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
pnpm run setup-installable-branch preview/pr-${{ github.event.pull_request.number }}
git push --force --set-upstream origin preview/pr-${{ github.event.pull_request.number }}
echo "pushed installable branch: https://github.com/$GITHUB_REPOSITORY/commit/$(git rev-parse HEAD)"
pnpm run pr-preview comment ${{ github.event.pull_request.number }} preview/pr-${{ github.event.pull_request.number }}
# Build and normal push for experimental releases to avoid unintended force
# pushes over remote branches in case of a branch name collision
- name: Build/push branch (workflow_dispatch)
if: github.event_name == 'workflow_dispatch'
run: |
pnpm run setup-installable-branch ${{ inputs.installableBranch }}
git push --set-upstream origin ${{ inputs.installableBranch }}
echo "💿 pushed installable branch: https://github.com/$GITHUB_REPOSITORY/commit/$(git rev-parse HEAD)"
# Cleanup PR preview/pr-{number} branches when the PR is closed
- name: Cleanup preview branch
if: github.event_name == 'pull_request' && github.event.pull_request.state == 'closed'
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
pnpm run pr-preview cleanup ${{ github.event.pull_request.number }} preview/pr-${{ github.event.pull_request.number }}