From b2dae2d5c8c0d84b1dedd72b372fcf911ffb1661 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Thu, 29 Aug 2024 08:27:49 +0200 Subject: [PATCH] chore: merging preview.yml and release.yml workflows --- .github/workflows/preview.yml | 48 ----------------------------------- .github/workflows/release.yml | 19 ++++++++------ release.config.mjs | 10 ++++++++ 3 files changed, 21 insertions(+), 56 deletions(-) delete mode 100644 .github/workflows/preview.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml deleted file mode 100644 index 9ccea3f2..00000000 --- a/.github/workflows/preview.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Build and Deploy Preview environment on Vercel -on: - pull_request: - branches: ['main'] - -jobs: - deploy-job: - runs-on: ubuntu-latest - - # Update the "Preview" environment with the Vercel deployed URL - environment: - name: Preview - url: ${{ steps.vercel-deploy.outputs.deployment_url }} - - steps: - - uses: actions/setup-node@v4 - - uses: actions/checkout@v4 - - id: vercel-deploy - run: | - npx -y vercel deploy --target=preview --token=${{ secrets.VERCEL_TOKEN }} \ - --build-env MDX=docs \ - --build-env NEXT_PUBLIC_LIBNAME="Poimandres" \ - --build-env NEXT_PUBLIC_LIBNAME_SHORT="pmndrs" \ - --build-env BASE_PATH= \ - --build-env DIST_DIR= \ - --build-env OUTPUT=export \ - --build-env HOME_REDIRECT= \ - --build-env MDX_BASEURL="https://github.com/${{ github.repository }}/raw/${{ github.head_ref }}/docs" \ - --build-env EDIT_BASEURL="https://github.com/${{ github.repository }}/edit/${{ github.head_ref }}/docs" \ - --build-env NEXT_PUBLIC_URL="$VERCEL_PROJECT_PRODUCTION_URL" \ - --build-env ICON="🖨️" \ - --build-env LOGO=gutenberg.jpg \ - --build-env GITHUB="https://github.com/${{ github.repository }}" \ - --build-env DISCORD="${{ secrets.DISCORD }}" \ - --build-env THEME_PRIMARY="#323e48" \ - --build-env THEME_SCHEME="tonalSpot" \ - --build-env THEME_CONTRAST="0" \ - --build-env THEME_NOTE="#1f6feb" \ - --build-env THEME_TIP="#238636" \ - --build-env THEME_IMPORTANT="#8957e5" \ - --build-env THEME_WARNING="#d29922" \ - --build-env THEME_CAUTION="#da3633" \ - > deployment-url.txt - - echo "deployment_url=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT - env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4f1bd2c0..7893c0d7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,9 @@ -name: Deploy Production environment on Vercel and Publish Docker image +name: Deploy on Vercel and Publish Docker image on: push: branches: ['main'] + pull_request: + branches: ['main'] env: REGISTRY: ghcr.io @@ -31,9 +33,9 @@ jobs: needs: semantic-release-job if: needs.semantic-release-job.outputs.new_release_version != '' - # Update the "Production" environment with the Vercel deployed URL + # Update the "Production"/"Preview" environment with the Vercel deployed URL environment: - name: Production + name: ${{ github.event_name == 'push' && 'Production' || 'Preview' }} url: ${{ steps.vercel-deploy.outputs.deployment_url }} steps: @@ -41,18 +43,19 @@ jobs: - uses: actions/checkout@v4 - id: vercel-deploy run: | - npx -y vercel deploy --target=production --token=${{ secrets.VERCEL_TOKEN }} \ + npx -y vercel deploy --token=${{ secrets.VERCEL_TOKEN }} \ + --target=${{ github.event_name == 'push' && 'production' || 'preview' }} \ --build-env MDX=docs \ --build-env NEXT_PUBLIC_LIBNAME="Poimandres" \ --build-env NEXT_PUBLIC_LIBNAME_SHORT="pmndrs" \ --build-env BASE_PATH= \ --build-env DIST_DIR= \ - --build-env OUTPUT= \ + --build-env OUTPUT=${{ github.event_name == 'push' && '' || 'export' }} \ --build-env HOME_REDIRECT= \ - --build-env MDX_BASEURL="https://github.com/${{ github.repository }}/raw/${{ github.ref_name }}/docs" \ - --build-env EDIT_BASEURL="https://github.com/${{ github.repository }}/edit/${{ github.ref_name }}/docs" \ + --build-env MDX_BASEURL="https://github.com/${{ github.repository }}/raw/${{ github.event_name == 'push' && github.ref_name || github.head_ref }}/docs" \ + --build-env EDIT_BASEURL="https://github.com/${{ github.repository }}/edit/${{ github.event_name == 'push' && github.ref_name || github.head_ref }}/docs" \ --build-env NEXT_PUBLIC_URL="$VERCEL_PROJECT_PRODUCTION_URL" \ - --build-env ICON= \ + --build-env ICON=${{ github.event_name == 'push' && '' || '🖨️' }} \ --build-env LOGO=gutenberg.jpg \ --build-env GITHUB="https://github.com/${{ github.repository }}" \ --build-env DISCORD="${{ secrets.DISCORD }}" \ diff --git a/release.config.mjs b/release.config.mjs index 0d3d0f16..6dbbf116 100644 --- a/release.config.mjs +++ b/release.config.mjs @@ -1,5 +1,15 @@ /** @type {import('semantic-release').GlobalConfig} */ const config = { + branches: [ + '+([0-9])?(.{+([0-9]),x}).x', + 'master', + 'main', + 'next', + 'next-major', + { name: 'beta', prerelease: true }, + { name: 'alpha', prerelease: true }, + { name: 'canary-*', prerelease: true }, + ], plugins: [ '@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator',