Last active
October 4, 2024 22:56
-
-
Save techwizzdom/87a286b8fad6bd5fb476de7df0e21549 to your computer and use it in GitHub Desktop.
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
name: CI/CD | |
concurrency: | |
group: ${{ github.head_ref || github.ref_name }} | |
cancel-in-progress: true | |
on: | |
push: | |
branches: | |
- staging | |
pull_request: | |
branches: | |
- staging | |
jobs: | |
build-and-test: | |
name: π Build, lint, and run unit tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: π₯ Checkout code and setup node | |
uses: actions/checkout@v3 | |
- name: π§ Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: βοΈ Install and build | |
run: | | |
npm install | |
npm run build | |
- name: ποΈ Linting | |
run: npm run lint | |
- name: π§ͺ Unit Tests | |
run: npm run test | |
deploy-preview-staging: | |
name: ποΈ Deploy to Preview Staging | |
if: github.ref == 'refs/heads/staging' && github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- name: π₯ Checkout code | |
uses: actions/checkout@v3 | |
- name: π§ Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: βοΈ Install and build | |
run: | | |
npm install | |
npm run build | |
- name: Install Vercel CLI | |
run: npm install --global vercel@latest | |
- name: Pull Vercel Environment Information | |
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN_TSB }} | |
- name: Build Project Artifacts | |
run: vercel build --token=${{ secrets.VERCEL_TOKEN_TSB }} | |
- name: Deploy to Vercel (Preview Staging) | |
run: | | |
url=$(vercel deploy --skip-domain --prebuilt --token=${{ secrets.VERCEL_TOKEN_TSB }} --scope=drombas-projects) | |
vercel alias --token=${{ secrets.VERCEL_TOKEN_TSB }} --scope=drombas-projects set "$url" preview-staging.thesecondbrain.io | |
e2e-tests-cypress-staging: | |
name: π² Cypress e2e Tests Staging | |
if: github.ref == 'refs/heads/staging' | |
needs: deploy-preview-staging | |
runs-on: ubuntu-latest | |
steps: | |
- name: π₯ Checkout code | |
uses: actions/checkout@v3 | |
- name: π§ Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: βοΈ Install and build | |
run: | | |
npm install | |
npm run build | |
- name: π Run E2E tests | |
run: npm run cy:run:preview-staging | |
- name: Upload Cypress Videos | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cypress-videos | |
path: cypress/videos | |
- name: Upload Cypress Screenshots | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cypress-screenshots | |
path: cypress/screenshots | |
deploy-staging: | |
name: π§ Deploy to Staging | |
if: github.ref == 'refs/heads/staging' | |
needs: e2e-tests-cypress-staging | |
runs-on: ubuntu-latest | |
steps: | |
- name: π₯ Checkout code | |
uses: actions/checkout@v3 | |
- name: π§ Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: βοΈ Install and build | |
run: | | |
npm install | |
npm run build | |
- name: Install Vercel CLI | |
run: npm install --global vercel@latest | |
- name: Pull Vercel Environment Information | |
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN_TSB }} | |
- name: Build Project Artifacts | |
run: vercel build --token=${{ secrets.VERCEL_TOKEN_TSB }} | |
- name: Deploy Project Artifacts to Vercel | |
run: | | |
url="$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN_TSB }} --scope=drombas-projects)" | |
vercel alias --token=${{ secrets.VERCEL_TOKEN_TSB }} --scope=drombas-projects set "$url" staging.thesecondbrain.io | |
merge-to-main: | |
name: π Merge to main | |
if: success() | |
runs-on: ubuntu-latest | |
needs: deploy-staging | |
steps: | |
- name: π₯ Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config user.name "GitHub Actions Lad" | |
git config user.email "<gh@email.io>" | |
- name: Merge Staging into Main | |
run: | | |
git fetch origin staging | |
git merge --ff-only FETCH_HEAD | |
git push origin main | |
- name: Push to Main | |
run: git push https://${{secrets.MERGE_TO_MAIN_PERSONAL_TOKEN}}@github.com/${{github.repository}} main | |
deploy-preview-production: | |
name: ποΈ Deploy to Preview Production | |
needs: merge-to-main | |
runs-on: ubuntu-latest | |
steps: | |
- name: π₯ Checkout code | |
uses: actions/checkout@v3 | |
- name: π§ Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: βοΈ Install and build | |
run: | | |
npm install | |
npm run build | |
- name: Install Vercel CLI | |
run: npm install --global vercel@latest | |
- name: Pull Vercel Environment Information | |
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN_TSB }} | |
- name: Build Project Artifacts | |
run: vercel build --token=${{ secrets.VERCEL_TOKEN_TSB }} | |
- name: Deploy Project Artifacts to Vercel | |
run: | | |
url="$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN_TSB }} --scope=drombas-projects)" | |
vercel alias --token=${{ secrets.VERCEL_TOKEN_TSB }} --scope=drombas-projects set "$url" preview-prod.thesecondbrain.io | |
e2e-tests-cypress-production: | |
name: π² Cypress e2e Tests Production | |
needs: deploy-preview-production | |
runs-on: ubuntu-latest | |
steps: | |
- name: π₯ Checkout code | |
uses: actions/checkout@v3 | |
- name: π§ Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: βοΈ Install and build | |
run: | | |
npm install | |
npm run build | |
- name: π Run E2E tests | |
run: npm run cy:run:preview-production | |
- name: Upload Cypress Videos | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cypress-videos | |
path: cypress/videos | |
- name: Upload Cypress Screenshots | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cypress-screenshots | |
path: cypress/screenshots | |
deploy-main: | |
name: π Deploy to Production | |
needs: e2e-tests-cypress-production | |
runs-on: ubuntu-latest | |
steps: | |
- name: π₯ Checkout code | |
uses: actions/checkout@v3 | |
- name: π§ Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: βοΈ Install and build | |
run: | | |
npm install | |
npm run build | |
- name: π Deploy to Vercel Production | |
uses: amondnet/vercel-action@v20 | |
with: | |
vercel-token: ${{ secrets.VERCEL_TOKEN_TSB }} | |
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} | |
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} | |
vercel-args: "--prod" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi @techwizzdom
I'm hoping can you help me with integration testing for the services, particularly focusing on ensuring that all services are properly tested before deployment.
Specifically, I need help with:
Setting up integration tests for services using [node, python].
Writing test cases that check the interactions between connected services.
Configuring GitHub Actions to automate running these tests before deployment.
it would be great if you could help me with this, Thanks.