Skip to content

Commit

Permalink
ci: refactor deploy workflows (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
voice0726 authored Feb 21, 2025
1 parent 2c6623b commit 6384e9a
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 51 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/actions/deploy-preview/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
outputs:
url:
description: URL of deployed preview
value: ${{ steps.deploy.outputs.url }}

inputs:
VERCEL_TOKEN:
description: vercel token
required: true

runs:
using: composite
steps:
- name: Initialize environment
uses: ./.github/workflows/actions/init
- name: Install Vercel CLI
run: pnpm install --global vercel@latest
shell: bash
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ inputs.VERCEL_TOKEN }}
shell: bash
- name: Build Project Artifacts
run: vercel build --token=${{ inputs.VERCEL_TOKEN }}
shell: bash
- name: Deploy Project Artifacts to Vercel
id: deploy
run: echo "url=$(vercel deploy --prebuilt --token=${{ inputs.VERCEL_TOKEN }})" >> $GITHUB_OUTPUT
shell: bash
24 changes: 24 additions & 0 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Deploy preview

on:
push:

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

jobs:
deploy:
if: ${{ github.ref_name != 'main' }}
runs-on: ubuntu-latest
environment:
name: preview
url: ${{ steps.deploy.outputs.url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy preview
id: deploy-preview
uses: ./.github/workflows/actions/deploy-preview
with:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy preview

on:
push:
branches:
- main

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: preview
url: ${{ steps.deploy.outputs.url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy preview
id: deploy-preview
uses: ./.github/workflows/actions/deploy-preview
with:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
- name: Assign staging domain to deployment
run: vercel alias ${{ steps.deploy-preview.outputs.url }} staging-voice0726.vercel.app --scope=voice726 --token=${{ secrets.VERCEL_TOKEN }}
50 changes: 0 additions & 50 deletions .github/workflows/deploy.yml

This file was deleted.

23 changes: 22 additions & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: release-please
name: Release please

on:
push:
Expand All @@ -9,6 +9,10 @@ permissions:
contents: write
pull-requests: write

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

jobs:
release-please:
runs-on: ubuntu-latest
Expand All @@ -27,3 +31,20 @@ jobs:
# optional. customize path to .release-please-manifest.json
manifest-file: .release-please-manifest.json
target-branch: main
prod:
needs: release-please
if: ${{ needs.release-please.outputs.release_created }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize environment
uses: ./.github/workflows/actions/init
- name: Install Vercel CLI
run: pnpm install --global vercel@latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_TOKEN }}

0 comments on commit 6384e9a

Please # to comment.