feat: add new project detail sections #774
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 - Preview | |
on: | |
pull_request: | |
types: | |
- opened | |
- edited | |
- synchronize | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Cancel Previous Runs | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ github.token }} | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
# Cache node modules and next folder | |
- name: Caching | |
uses: actions/cache@v2 | |
with: | |
path: | | |
**/node_modules | |
${{ github.workspace }}/.next/cache | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }} | |
# Setup deployment environment config | |
# We want each branch deployment to be of its own preview env | |
- name: Setup deployment | |
uses: bobheadxi/[email protected] | |
id: deployment | |
with: | |
step: start | |
token: ${{ github.token }} | |
env: preview-${{ github.head_ref }} | |
ref: ${{ github.head_ref }} | |
- name: Install dependencies | |
run: pnpm i --shamefully-hoist | |
# Build & deploy the app | |
- name: Build & Deploy | |
id: build_and_deploy | |
run: | | |
COMMAND="netlify deploy --build -m ${{ github.head_ref }} --alias pr-${{ github.event.number }}" | |
OUTPUT=$(sh -c "$COMMAND") | |
NETLIFY_LIVE_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*(--)[a-zA-Z0-9./?=_-]*') # Unique key: -- | |
NETLIFY_LOGS_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://app.netlify.com/[a-zA-Z0-9./?=_-]*') # Unique key: app.netlify.com | |
echo "netlify_live_url=$NETLIFY_LIVE_URL" >> $GITHUB_OUTPUT | |
echo "netlify_logs_url=$NETLIFY_LOGS_URL" >> $GITHUB_OUTPUT | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
- name: Update deployment status | |
uses: bobheadxi/[email protected] | |
if: always() | |
with: | |
step: finish | |
token: ${{ github.token }} | |
status: ${{ job.status }} | |
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | |
logs: ${{ steps.build_and_deploy.outputs.netlify_logs_url }} | |
env_url: ${{ steps.build_and_deploy.outputs.netlify_live_url }} |