Configure Renovate #63
Workflow file for this run
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: CI | |
on: | |
push: | |
pull_request_target: | |
types: [opened, synchronize] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-buildx-action@v3 | |
- uses: crazy-max/ghaction-github-runtime@v3 | |
- uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: pnpm | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build | |
run: pnpm build | |
- name: Publish | |
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v') | |
id: publish | |
run: | | |
pnpm config set '//registry.npmjs.org/:_authToken' '${{ secrets.NPM_TOKEN }}' | |
pnpm -r publish --provenance --access public --no-git-checks | |
- name: Publish (dry-run) | |
if: steps.publish.outcome != 'success' | |
run: pnpm -r publish --dry-run --no-git-checks | |
- name: Fild dist directories | |
id: find-dists | |
run: | | |
echo 'dirs<<EOF' >> $GITHUB_OUTPUT | |
for dir in $(find . -type d -name "*dist" -not -path "*/node_modules/*"); do | |
echo $dir >> $GITHUB_OUTPUT | |
done | |
echo 'EOF' >> $GITHUB_OUTPUT | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: dists | |
path: ${{ steps.find-dists.outputs.dirs }} | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
# If push event triggered, it must not be a pull request | |
if: github.event_name != 'push' || !startsWith(github.ref, 'refs/pull/') | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
DEPLOY_ENV: ${{ github.ref == 'refs/heads/main' && 'production' || 'preview' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
- uses: actions/download-artifact@v4 | |
with: | |
name: dists | |
- uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: pnpm | |
- name: Install Vercel CLI | |
run: pnpm install --global vercel@latest | |
- name: Pull Vercel Environment Information | |
run: vercel pull --yes --environment=${{ env.DEPLOY_ENV }} --token=${{ env.VERCEL_TOKEN }} | |
- name: Build Project Artifacts (Production) | |
if: env.DEPLOY_ENV == 'production' | |
run: vercel build --prod --token=${{ env.VERCEL_TOKEN }} | |
- name: Build Project Artifacts (Preview) | |
if: env.DEPLOY_ENV == 'preview' | |
run: vercel build --token=${{ env.VERCEL_TOKEN }} | |
- name: Deploy Project Artifacts to Vercel (Production) | |
if: env.DEPLOY_ENV == 'production' | |
run: vercel deploy --prebuilt --prod --token=${{ env.VERCEL_TOKEN }} | |
- name: Deploy Project Artifacts to Vercel (Preview) | |
if: env.DEPLOY_ENV == 'preview' | |
run: vercel deploy --prebuilt --token=${{ env.VERCEL_TOKEN }} |