Skip to content

Commit

Permalink
chore(CI): separate deploy workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
macrat committed Jan 1, 2024
1 parent 952bd04 commit c5a0257
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 85 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ on:
push:

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.21.x
- uses: actions/checkout@v3
- run: cd builder && go test -race ./...

build:
name: Build
runs-on: ubuntu-latest
Expand Down
85 changes: 0 additions & 85 deletions .github/workflows/deploy.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: preview

on:
workflow_run:
workflows: [build]
types: [completed]
branches-ignore:
- master
- photos

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

jobs:
preview:
name: Deploy
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
environment:
name: preview
url: ${{ steps.deploy.outputs.url }}
steps:
- name: Instal Vercel CLI
run: npm install --global vercel@latest

- name: Load artifact
uses: actions/download-artifact@v4
with: dist

- name: Pull Vercel environment information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy to Vercel
id: deploy
run: |
echo -n "url=" >> $GITHUB_OUTPUT
vercel deploy --token=${{ secrets.VERCEL_TOKEN }} >> $GITHUB_OUTPUT
37 changes: 37 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: production

on:
workflow_run:
workflows: [build]
types: [completed]
branches:
- master
- photos

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

jobs:
production:
name: Deploy
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
environment:
name: production
url: ${{ steps.deploy.outputs.url }}
steps:
- name: Instal Vercel CLI
run: npm install --global vercel@latest

- name: Load artifact
uses: actions/download-artifact@v4
with: dist

- name: Pull Vercel environment information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy to Vercel
id: deploy
run: |
echo -n "url=" >> $GITHUB_OUTPUT
vercel deploy --token=${{ secrets.VERCEL_TOKEN }} --prod >> $GITHUB_OUTPUT

0 comments on commit c5a0257

Please sign in to comment.