|
| 1 | +# Create "installable" preview branches |
| 2 | +# |
| 3 | +# Commits to `dev` push builds to a `preview/dev` branch: |
| 4 | +# pnpm install "remix-run/react-router#preview/dev&path:packages/react-router" |
| 5 | +# |
| 6 | +# Can also be dispatched manually with base/installable branches to provide |
| 7 | +# `experimental` branches from PRs or otherwise. |
| 8 | + |
| 9 | +name: Preview Build |
| 10 | + |
| 11 | +on: |
| 12 | + push: |
| 13 | + branches: |
| 14 | + - dev |
| 15 | + workflow_dispatch: |
| 16 | + inputs: |
| 17 | + baseBranch: |
| 18 | + description: Base Branch |
| 19 | + required: true |
| 20 | + installableBranch: |
| 21 | + description: Installable Branch |
| 22 | + required: true |
| 23 | + |
| 24 | +concurrency: |
| 25 | + # Include `event_name` here because when a pull_request is merged (closed), the |
| 26 | + # `github.ref` goes back to `ref/heads/dev` which will conflict with the run on |
| 27 | + # `dev` from the merged PR |
| 28 | + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} |
| 29 | + cancel-in-progress: true |
| 30 | + |
| 31 | +jobs: |
| 32 | + preview: |
| 33 | + if: github.repository == 'remix-run/react-router' |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - name: Checkout (push) |
| 37 | + if: github.event_name == 'push' |
| 38 | + uses: actions/checkout@v4 |
| 39 | + |
| 40 | + - name: Checkout (workflow_dispatch) |
| 41 | + if: github.event_name == 'workflow_dispatch' |
| 42 | + uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + ref: ${{ inputs.baseBranch }} |
| 45 | + |
| 46 | + - name: Install pnpm |
| 47 | + uses: pnpm/action-setup@v4 |
| 48 | + |
| 49 | + - name: Install Node.js |
| 50 | + uses: actions/setup-node@v4 |
| 51 | + with: |
| 52 | + node-version-file: "package.json" |
| 53 | + cache: pnpm |
| 54 | + |
| 55 | + - name: Install dependencies |
| 56 | + run: pnpm install --frozen-lockfile |
| 57 | + |
| 58 | + - name: Setup git |
| 59 | + run: | |
| 60 | + git config --local user.email "hello@remix.run" |
| 61 | + git config --local user.name "Remix Run Bot" |
| 62 | +
|
| 63 | + # Build and force push over the preview/dev branch |
| 64 | + - name: Build/push branch (push) |
| 65 | + if: github.event_name == 'push' |
| 66 | + run: | |
| 67 | + pnpm run setup-installable-branch preview/dev |
| 68 | + git push --force --set-upstream origin preview/dev |
| 69 | + echo "💿 pushed installable branch: https://github.com/$GITHUB_REPOSITORY/commit/$(git rev-parse HEAD)" |
| 70 | +
|
| 71 | + # Build and normal push for experimental releases to avoid unintended force |
| 72 | + # pushes over remote branches in case of a branch name collision |
| 73 | + - name: Build/push branch (workflow_dispatch) |
| 74 | + if: github.event_name == 'workflow_dispatch' |
| 75 | + run: | |
| 76 | + pnpm run setup-installable-branch ${{ inputs.installableBranch }} |
| 77 | + git push --set-upstream origin ${{ inputs.installableBranch }} |
| 78 | + echo "💿 pushed installable branch: https://github.com/$GITHUB_REPOSITORY/commit/$(git rev-parse HEAD)" |
0 commit comments