Skip to content

Commit

Permalink
chore: modify gha
Browse files Browse the repository at this point in the history
  • Loading branch information
Kohei Asai committed Feb 3, 2024
1 parent 51b580d commit db716da
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
13 changes: 11 additions & 2 deletions .github/actions/vercel-deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,18 @@ runs:
- name: Prepare for Vercel CLI
run: |
mkdir .vercel
echo "${{ "{" }} \"projectId\": \"${{ inputs.vercel-project-id }}\", \"orgId\": \"${{ inputs.vercel-org-id }}\" ${{ "}" }}" > .vercel/project.json
echo "{}" \
| jq -c \
'.projectId|="${{ inputs.vercel-project-id }}"' \
'.orgId|="${{ inputs.vercel-org-id }}"' \
> .vercel/project.json
shell: bash
- name: Deploy
- name: Restore the Build from Artifacts
uses: actions/download-artifact@v4
with:
name: vercel-build-${{ github.sha }}
path: .vercel/output
- name: Vercel Deploy
id: deployment
run: |
npx vercel deploy \
Expand Down
44 changes: 41 additions & 3 deletions .github/actions/vercel-prebuild/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,58 @@ inputs:
vercel-project-id:
description: The project id at Vercel
required: true
vercel-token:
description: The auth token for Vercel
required: true
build-command:
description: The shell command to build the application
default: npm run build
branch:
description: The Git branch. Keep empty for production deployments
runs:
using: "composite"
steps:
- name: Prepare for Vercel CLI
- name: Prepare for Vercel Prebuild
if: ${{ inputs.branch == null }}
run: |
mkdir .vercel
echo "{}" \
| jq -c \
'.projectId|="${{ inputs.vercel-project-id }}"' \
'.orgId|="${{ inputs.vercel-org-id }}"' \
> .vercel/project.json
npx vercel pull \
--token=${{ inputs.vercel-token }} \
--environment=production
cat .vercel/project.json \
| jq -c \
'.buildCommand|="${{ inputs.build-command }}"' \
> .vercel/project.json
shell: bash
- name: Prepare for Vercel Prebuild
if: ${{ inputs.branch != null }}
run: |
mkdir .vercel
echo "${{ "{" }} \"projectId\": \"${{ inputs.vercel-project-id }}\", \"orgId\": \"${{ inputs.vercel-org-id }}\", \"settings\": ${{ "{" }} \"createdAt\": 0, \"framework\": \"nextjs\", \"devCommand\": null, \"buildCommand\": \"next build\", \"outputDirectory\": null, \"rootDirectory\": null, \"directoryListing\": false, \"nodeVersion\": \"20.x\", \"analyticsId\": null ${{ "}" }} ${{ "}" }}" > .vercel/project.json
echo "{}" \
| jq -c \
'.projectId|="${{ inputs.vercel-project-id }}"' \
'.orgId|="${{ inputs.vercel-org-id }}"' \
> .vercel/project.json
npx vercel pull \
--token=${{ inputs.vercel-token }} \
--environment=preview \
--git-branch=${{ inputs.branch }}
cat .vercel/project.json \
| jq -c \
'.buildCommand|="${{ inputs.build-command }}"' \
> .vercel/project.json
shell: bash
- name: Build
run: npx vercel build
shell: bash
- name: Store the Build as Artifacts
uses: actions/upload-artifact@v4
with:
name: vercel-build
name: vercel-build-${{ github.sha }}
path: .vercel/output
if-no-files-found: error
3 changes: 3 additions & 0 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ jobs:
with:
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
vercel-token: ${{ secrets.VERCEL_TOKEN }}
branch: ${{ github.ref_name }}
build-command: npx next build
deploy:
name: Deploy
needs:
Expand Down

0 comments on commit db716da

Please sign in to comment.