diff --git a/.github/workflows/pipe.yml b/.github/workflows/pipe.yml index 4401c9e..dfc5729 100644 --- a/.github/workflows/pipe.yml +++ b/.github/workflows/pipe.yml @@ -8,7 +8,7 @@ on: jobs: # Task 1: Cache and Build build: - runs-on: ubuntu-latest # Use the latest Ubuntu environment for the build. + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 @@ -46,24 +46,31 @@ jobs: run: npm run build # Build the application using the `npm run build` command. + - name: Cache `out` folder + uses: actions/cache@v3 + with: + path: out + key: ${{ runner.os }}-out-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-out- + # Cache the `out` folder containing the static files for deployment. + - name: Verify export output run: ls -la ./out # Verify that the `out` folder was created successfully. # Task 2: Linting lint: - runs-on: ubuntu-latest # Use the latest Ubuntu environment for linting. - needs: build # This job depends on the completion of the "build" job. + runs-on: ubuntu-latest + needs: build steps: - name: Checkout code uses: actions/checkout@v2 - # Check out the code from the repository. - name: Set up Node.js uses: actions/setup-node@v2 with: node-version: '21' - # Set up Node.js version 21 for linting. - name: Cache Node.js modules uses: actions/cache@v3 @@ -72,30 +79,25 @@ jobs: key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }} restore-keys: | ${{ runner.os }}-node-modules- - # Cache the Node.js modules (node_modules) for faster dependency installation. - name: Install dependencies run: npm ci - # Install dependencies for the linting process. - name: Run linting run: npm run lint - # Run the linting process to check for code style and errors. # Task 3: Testing test: - runs-on: ubuntu-latest # Use the latest Ubuntu environment for testing. - needs: build # This job depends on the completion of the "build" job. + runs-on: ubuntu-latest + needs: build steps: - name: Checkout code uses: actions/checkout@v2 - # Check out the code from the repository. - name: Set up Node.js uses: actions/setup-node@v2 with: node-version: '21' - # Set up Node.js version 21 for testing. - name: Cache Node.js modules uses: actions/cache@v3 @@ -104,38 +106,38 @@ jobs: key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }} restore-keys: | ${{ runner.os }}-node-modules- - # Cache the Node.js modules (node_modules) for faster dependency installation. - name: Install dependencies run: npm ci - # Install dependencies required for the tests. - - - name: Cache .next folder - uses: actions/cache@v3 - with: - path: .next - key: ${{ runner.os }}-next-${{ hashFiles('package-lock.json') }} - restore-keys: | - ${{ runner.os }}-next- - # Cache the `.next` folder to reuse the build output during testing. - name: Run tests run: npm test - # Run the tests to verify application functionality. # Task 4: Deploy to GitHub Pages deploy: - runs-on: ubuntu-latest # Use the latest Ubuntu environment for deployment. - needs: [lint, test] # This job depends on the completion of both "lint" and "test" jobs. + runs-on: ubuntu-latest + needs: [lint, test] steps: - name: Checkout code uses: actions/checkout@v2 - # Check out the code from the repository. + + - name: Restore `out` folder cache + uses: actions/cache@v3 + with: + path: out + key: ${{ runner.os }}-out-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-out- + # Restore the cached `out` folder to deploy the prebuilt static files. + + - name: Verify export output before deploy + run: ls -la ./out + # Verify that the `out` folder exists before deployment. - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./out + publish_dir: out force_orphan: true # Deploy the static files from the `out` directory to GitHub Pages.