diff --git a/.github/workflows/ci-cd-dev.yaml b/.github/workflows/ci-cd-dev.yaml new file mode 100644 index 0000000..4b644d0 --- /dev/null +++ b/.github/workflows/ci-cd-dev.yaml @@ -0,0 +1,19 @@ +name: CI/CD Pipeline (dev) +on: + push: + branches: + - refactor + pull_request: + branches: + - refactor +jobs: + test: + uses: ./.github/workflows/jobs/test.yml + deploy-vercel: + needs: [test] + uses: ./.github/workflows/jobs/deploy-vercel.yml + e2e: + needs: [deploy-vercel] + uses: ./.github/workflows/jobs/e2e.yml + with: + env: dev \ No newline at end of file diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml deleted file mode 100644 index 19d6f5e..0000000 --- a/.github/workflows/ci-cd.yml +++ /dev/null @@ -1,123 +0,0 @@ -name: CI/CD Pipeline -on: - push: - branches: - - refactor -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'yarn' - - - name: Cache dependencies - id: dependencies-cache - uses: actions/cache@v3 - with: - key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} - path: '**/node_modules' - restore-keys: | - ${{ runner.os }}-node- - - - name: Install Packages - if: steps.dependencies-cache.outputs.cache-hit != 'true' - run: yarn install - - - name: Run Unit and Integration Tests - run: yarn run test - deploy-vercel: - runs-on: ubuntu-latest - needs: [test] - env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install Vercel CLI - run: npm install --global vercel@latest - - - name: Pull Vercel Environment Information - run: | - if [ "${{ github.ref }}" == "refs/heads/main" ]; then - vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}; - else - vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}; - fi - - - name: Build Project Artifacts - run: | - if [ "${{ github.ref }}" == "refs/heads/main" ]; then - vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}; - else - vercel build --token=${{ secrets.VERCEL_TOKEN }}; - fi - - - name: Deploy Project Artifacts to Vercel - run: | - if [ "${{ github.ref }}" == "refs/heads/main" ]; then - vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}; - else - vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}; - fi - e2e: - runs-on: ubuntu-latest - needs: [deploy-vercel] - env: - APP_ENV: dev - NOTION_ROOT_PAGE_ID: ${{ secrets.NOTION_ROOT_PAGE_ID }} - NOTION_ACTIVE_USER_ID: ${{ secrets.NOTION_ACTIVE_USER_ID }} - NOTION_AUTH_TOKEN: ${{ secrets.NOTION_AUTH_TOKEN }} - NOTION_API_TOKEN: ${{ secrets.NOTION_API_TOKEN }} - NOTION_DB_ID: ${{ secrets.NOTION_DB_ID }} - NOTION_PORTFOLIO_PAGE_ID: ${{ secrets.NOTION_PORTFOLIO_PAGE_ID }} - BLOG_ODR_TOKEN: ${{ secrets.BLOG_ODR_TOKEN }} - NEXT_PUBLIC_GA_ID: ${{ secrets.NEXT_PUBLIC_GA_ID }} - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'yarn' - - - name: Cache dependencies - id: dependencies-cache - uses: actions/cache@v3 - with: - key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} - path: '**/node_modules' - restore-keys: | - ${{ runner.os }}-node- - - - - name: Install Packages - if: steps.dependencies-cache.outputs.cache-hit != 'true' - run: yarn install - - - name: Build project - run: yarn build - - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - - name: Start e2e test - run: | - echo "APP_ENV is ${{ env.APP_ENV }}" - yarn e2e - - - uses: actions/upload-artifact@v4 - if: ${{ !cancelled() }} - with: - name: playwright-report - path: playwright-report/ - retention-days: 30