-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup initial CI and CD workflow files (#41)
- Loading branch information
Showing
4 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,26 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Run tests | ||
run: npm test | ||
|
||
- name: Build application | ||
run: npm run build |
This file contains 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,28 @@ | ||
name: Live Deployment | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- staging | ||
|
||
env: | ||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | ||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | ||
|
||
jobs: | ||
deploy-preproduction-preview: | ||
uses: ./.github/workflows/deploy.yml | ||
if: github.ref_name == 'staging' | ||
with: | ||
environment: preproduction | ||
preview: false | ||
secrets: inherit | ||
deploy-production-preview: | ||
uses: ./.github/workflows/deploy.yml | ||
if: github.ref_name == 'main' | ||
with: | ||
environment: production | ||
preview: false | ||
secrets: inherit | ||
|
This file contains 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,28 @@ | ||
name: Preview Deployment | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
- staging | ||
|
||
env: | ||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | ||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | ||
|
||
jobs: | ||
deploy-preproduction-preview: | ||
uses: ./.github/workflows/deploy.yml | ||
if: github.base_ref == 'staging' | ||
with: | ||
environment: preproduction | ||
preview: true | ||
secrets: inherit | ||
deploy-production-preview: | ||
uses: ./.github/workflows/deploy.yml | ||
if: github.base_ref == 'main' | ||
with: | ||
environment: production | ||
preview: true | ||
secrets: inherit | ||
|
This file contains 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,60 @@ | ||
name: Deploy to Vercel | ||
on: | ||
workflow_call: | ||
inputs: | ||
environment: | ||
required: true | ||
type: string | ||
preview: | ||
required: false | ||
type: boolean | ||
default: true | ||
|
||
env: | ||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | ||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '20' | ||
- name: Install dependencies | ||
run: npm install | ||
- name: Run tests | ||
run: npm test | ||
deploy-preview: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
environment: ${{ inputs.environment }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Set up environment variables | ||
run: | | ||
echo "VERCEL_ORG_ID=${{ secrets.VERCEL_ORG_ID }}" >> $GITHUB_ENV | ||
echo "VERCEL_PROJECT_ID=${{ secrets.VERCEL_PROJECT_ID }}" >> $GITHUB_ENV | ||
if [ ${{ inputs.preview }} = true ]; then | ||
echo "VERCEL_ENVIRONMENT=preview" >> $GITHUB_ENV | ||
echo "VERCEL_DEPLOYMENT_FLAG=" >> $GITHUB_ENV | ||
else | ||
echo "VERCEL_ENVIRONMENT=production" >> $GITHUB_ENV | ||
echo "VERCEL_DEPLOYMENT_FLAG=--prod" >> $GITHUB_ENV | ||
fi | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '20' | ||
- name: Install dependencies | ||
run: npm install | ||
- name: Install Vercel CLI | ||
run: npm install -g vercel | ||
- name: Pull Vercel Environment Information | ||
run: vercel pull --yes --environment=$VERCEL_ENVIRONMENT --token=${{ secrets.VERCEL_TOKEN }} | ||
- name: Deploy to Vercel Preview | ||
run: vercel $VERCEL_DEPLOYMENT_FLAG --token=${{ secrets.VERCEL_TOKEN }} |