diff --git a/.github/workflows/actions/deploy-preview/action.yml b/.github/workflows/actions/deploy-preview/action.yml new file mode 100644 index 0000000..e0fe9e1 --- /dev/null +++ b/.github/workflows/actions/deploy-preview/action.yml @@ -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 diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml new file mode 100644 index 0000000..d460ad3 --- /dev/null +++ b/.github/workflows/deploy-preview.yml @@ -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 }} diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml new file mode 100644 index 0000000..8ba3a82 --- /dev/null +++ b/.github/workflows/deploy-staging.yml @@ -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 }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 79474f3..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: deploy to vercel - -on: - push: - -env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} - -jobs: - preview: - if: ${{ github.ref != 'refs/heads/release' }} - runs-on: ubuntu-latest - environment: - name: preview - url: ${{ steps.deploy.outputs.url }} - 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=preview --token=${{ secrets.VERCEL_TOKEN }} - - name: Build Project Artifacts - run: vercel build --token=${{ secrets.VERCEL_TOKEN }} - - name: Deploy Project Artifacts to Vercel - id: deploy - run: echo "url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})" >> $GITHUB_OUTPUT - - name: Assign staging domain to deployment (if main branch) - if: ${{ github.ref == 'refs/heads/main' }} - run: vercel alias ${{ steps.deploy.outputs.url }} staging-voice0726.vercel.app --scope=voice726 --token=${{ secrets.VERCEL_TOKEN }} - - prod: - if: ${{ github.ref == 'refs/heads/release' }} - 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 }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 4a50c93..a7f2b89 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -1,4 +1,4 @@ -name: release-please +name: Release please on: push: @@ -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 @@ -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 }} \ No newline at end of file