Skip to content

Project update to v2 #847

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

Merged
merged 8 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add .gitginore and gh actions workflow
  • Loading branch information
javiert-okta committed Jun 11, 2025
commit 808d2a679c8dea3488352ccacbdb51d674028df9
90 changes: 90 additions & 0 deletions .github/workflows/preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Vercel Preview Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
push:
branches-ignore:
- main
- production
jobs:
Deploy-Preview:
runs-on:
labels: ubuntu-22.04-2cpu-8ram-75ssd
environment: preview
outputs:
deploymentUrl: ${{ steps.deploy.outputs.deploymentUrl }}
steps:
- name: Checkout the Codebase
uses: actions/checkout@v4
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Deploy on Vercel
id: deploy
run: |
vercel deploy --token=${{ secrets.VERCEL_ACCESS_TOKEN }} > deploy.log
URL=$(cat deploy.log | grep -o 'https://[^ ]*.vercel.app' | head -n1)
echo "deploymentUrl=$URL" >> $GITHUB_OUTPUT
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Assign Custom Domain
if: ${{ steps.extract_branch.outputs.branch == 'remove-basepath-2' }}
run: |
vercel alias set --token=${{ secrets.VERCEL_ACCESS_TOKEN }} ${{ steps.deploy.outputs.deploymentUrl }} ab-test-next-jwt-io.vercel.app --scope=okta

Add-Comment:
runs-on:
labels: ubuntu-22.04-2cpu-8ram-75ssd
needs: Deploy-Preview
permissions:
issues: write
pull-requests: write
steps:
- name: Comment URL to PR
uses: actions/github-script@v6
id: comment-deployment-url-script
env:
DEPLOYMENT_URL: ${{ needs.Deploy-Preview.outputs.deploymentUrl }}
with:
script: |
// Get pull requests that are open for current ref.
const pullRequests = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:${context.ref.replace('refs/heads/', '')}`
})

// Set issue number for following calls from context (if on pull request event) or from above variable.
const issueNumber = context.issue.number || pullRequests.data[0].number

// Retrieve existing bot comments for the PR
const {data: comments} = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
})
const botComment = comments.find(comment => {
return comment.user.type === 'Bot' && comment.body.includes('Preview URL at')
})

const output = "Preview URL " + process.env.DEPLOYMENT_URL

// If we have a comment, update it, otherwise create a new one
if (botComment) {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: output
})
} else {
github.rest.issues.createComment({
issue_number: issueNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
}
22 changes: 22 additions & 0 deletions .github/workflows/production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Vercel Production Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
push:
branches:
- main
- production
jobs:
Deploy-Production:
runs-on:
labels: ubuntu-22.04-2cpu-8ram-75ssd
steps:
- name: Checkout the Codebase
uses: actions/checkout@v4
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Deploy on Vercel
id: deploy
run: |
vercel deploy --prod --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
Loading
Loading