-
Notifications
You must be signed in to change notification settings - Fork 1
Feat: Add Vercel workflows #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AdamJHall
wants to merge
3
commits into
main
Choose a base branch
from
feature/Add-Vercel-Workflows
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+233
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| name: Vercel Preview Deployment | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| vercel-org-id: | ||
| description: "Vercel organisation ID" | ||
| type: string | ||
| required: true | ||
| vercel-project-id: | ||
| description: "Vercel project ID" | ||
| type: string | ||
| required: true | ||
| working-directory: | ||
| description: "Directory to run the Vercel deploy from" | ||
| type: string | ||
| required: false | ||
| default: "." | ||
| environment-name: | ||
| description: "GitHub Environment to deploy to" | ||
| type: string | ||
| required: false | ||
| default: "Preview" | ||
| secrets: | ||
| vercel-token: | ||
| description: "Vercel deployment token" | ||
| required: true | ||
|
|
||
| concurrency: | ||
| group: vercel-preview-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| deploy-preview: | ||
| name: Deploy Preview to Vercel | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| deployments: write | ||
| pull-requests: write | ||
| environment: | ||
| name: ${{ inputs.environment-name }} | ||
| url: ${{ steps.deploy.outputs.url }} | ||
| env: | ||
| VERCEL_ORG_ID: ${{ inputs.vercel-org-id }} | ||
| VERCEL_PROJECT_ID: ${{ inputs.vercel-project-id }} | ||
| VERCEL_TELEMETRY_DISABLED: 1 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Install Vercel CLI | ||
| run: npm install --global vercel@latest | ||
|
|
||
| - name: Deploy to Vercel (preview) | ||
| id: deploy | ||
| working-directory: ${{ inputs.working-directory }} | ||
| env: | ||
| VERCEL_TOKEN: ${{ secrets.vercel-token }} | ||
| run: | | ||
| vercel deploy --yes --no-wait --token="$VERCEL_TOKEN" \ | ||
| > deployment-url.txt 2> >(tee vercel-output.log >&2) | ||
| url="$(cat deployment-url.txt)" | ||
| inspect_url="$(grep -m1 -o 'https://vercel.com/[^[:space:]]*' vercel-output.log || true)" | ||
| echo "url=$url" >> "$GITHUB_OUTPUT" | ||
| echo "inspect_url=$inspect_url" >> "$GITHUB_OUTPUT" | ||
|
|
||
| # Posts (or updates in place) a single comment on the PR with the preview URL. | ||
| - name: Comment preview URL on PR | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| REPO: ${{ github.repository }} | ||
| DEPLOY_URL: ${{ steps.deploy.outputs.url }} | ||
| INSPECT_URL: ${{ steps.deploy.outputs.inspect_url }} | ||
| COMMIT_SHA: ${{ github.event.pull_request.head.sha }} | ||
| run: | | ||
| marker='<!-- vercel-preview -->' | ||
| body="$marker | ||
| ### ⚡ Preview environment is deploying | ||
|
|
||
| Wait ~5 minutes for completion, or monitor progress using the Inspect URL. | ||
|
|
||
| **Preview URL:** ${DEPLOY_URL} | ||
| **Inspect:** ${INSPECT_URL} | ||
|
|
||
| _Deployed commit ${COMMIT_SHA}_" | ||
|
|
||
| comment_id="$(gh api "repos/${REPO}/issues/${PR_NUMBER}/comments" \ | ||
| --jq "[.[] | select(.body | startswith(\"${marker}\"))][0].id")" | ||
|
|
||
| if [ -n "$comment_id" ] && [ "$comment_id" != "null" ]; then | ||
| gh api -X PATCH "repos/${REPO}/issues/comments/${comment_id}" -f body="$body" | ||
| else | ||
| gh api -X POST "repos/${REPO}/issues/${PR_NUMBER}/comments" -f body="$body" | ||
| fi | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| name: Vercel Production Deployment | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| vercel-org-id: | ||
| description: "Vercel organisation ID" | ||
| type: string | ||
| required: true | ||
| vercel-project-id: | ||
| description: "Vercel project ID" | ||
| type: string | ||
| required: true | ||
| working-directory: | ||
| description: "Directory to run the Vercel deploy from" | ||
| type: string | ||
| required: false | ||
| default: "." | ||
| environment-name: | ||
| description: "GitHub Environment to deploy to" | ||
| type: string | ||
| required: false | ||
| default: "Production" | ||
| secrets: | ||
| vercel-token: | ||
| description: "Vercel deployment token" | ||
| required: true | ||
|
|
||
| concurrency: | ||
| group: vercel-production-${{ github.ref }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| deploy-production: | ||
| name: Deploy Production to Vercel | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| deployments: write | ||
| environment: | ||
| name: ${{ inputs.environment-name }} | ||
| url: ${{ steps.deploy.outputs.url }} | ||
| env: | ||
| VERCEL_ORG_ID: ${{ inputs.vercel-org-id }} | ||
| VERCEL_PROJECT_ID: ${{ inputs.vercel-project-id }} | ||
| VERCEL_TELEMETRY_DISABLED: 1 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Install Vercel CLI | ||
| run: npm install --global vercel@latest | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto here. |
||
|
|
||
| - name: Deploy to Vercel (production) | ||
| id: deploy | ||
| working-directory: ${{ inputs.working-directory }} | ||
| env: | ||
| VERCEL_TOKEN: ${{ secrets.vercel-token }} | ||
| run: | | ||
| url="$(vercel deploy --prod --yes --no-wait --token="$VERCEL_TOKEN")" | ||
| echo "url=$url" >> "$GITHUB_OUTPUT" | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Vercel Preview Deployment | ||
|
|
||
| Deploys a preview build to Vercel and posts (or updates) a single comment on the | ||
| pull request with the preview and inspect URLs. Intended to be called from a | ||
| `pull_request` triggered workflow. | ||
|
|
||
| #### **Inputs** | ||
| | Name | Required | Type | Default | Description | | ||
| |--------------------|----------|--------|----------|----------------------------------------| | ||
| | vercel-org-id | ✅ | string | | Vercel organisation ID | | ||
| | vercel-project-id | ✅ | string | | Vercel project ID | | ||
| | working-directory | ❌ | string | . | Directory to run the Vercel deploy from | | ||
| | environment-name | ❌ | string | Preview | GitHub Environment to deploy to | | ||
|
|
||
| #### **Secrets** | ||
| | Name | Required | Description | | ||
| |---------------|----------|--------------------------| | ||
| | vercel-token | ✅ | Vercel deployment token | | ||
|
|
||
| #### Example Usage | ||
|
|
||
| ```yaml | ||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| deploy-preview: | ||
| uses: aligent/workflows/.github/workflows/vercel-preview.yml@main | ||
| with: | ||
| vercel-org-id: ${{ vars.VERCEL_ORG_ID }} | ||
| vercel-project-id: ${{ vars.VERCEL_PROJECT_ID }} | ||
| secrets: | ||
| vercel-token: ${{ secrets.VERCEL_TOKEN }} | ||
| ``` |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Vercel Production Deployment | ||
|
|
||
| Deploys a production build to Vercel. Intended to be called from a `push` (or | ||
| `workflow_dispatch`) triggered workflow. | ||
|
|
||
| #### **Inputs** | ||
| | Name | Required | Type | Default | Description | | ||
| |--------------------|----------|--------|------------|----------------------------------------| | ||
| | vercel-org-id | ✅ | string | | Vercel organisation ID | | ||
| | vercel-project-id | ✅ | string | | Vercel project ID | | ||
| | working-directory | ❌ | string | . | Directory to run the Vercel deploy from | | ||
| | environment-name | ❌ | string | Production | GitHub Environment to deploy to | | ||
|
|
||
| #### **Secrets** | ||
| | Name | Required | Description | | ||
| |---------------|----------|--------------------------| | ||
| | vercel-token | ✅ | Vercel deployment token | | ||
|
|
||
| #### Example Usage | ||
|
|
||
| ```yaml | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| deploy-production: | ||
| uses: aligent/workflows/.github/workflows/vercel-production.yml@main | ||
| with: | ||
| vercel-org-id: ${{ vars.VERCEL_ORG_ID }} | ||
| vercel-project-id: ${{ vars.VERCEL_PROJECT_ID }} | ||
| secrets: | ||
| vercel-token: ${{ secrets.VERCEL_TOKEN }} | ||
| ``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we pin this to a specific version rather than use
@latestfor supply chain reasons?