diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 877f81c7..2d18b559 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -1,100 +1,55 @@ -name: Build and Test +name: Build Test Workflow on: push: - branches: [main, develop] - paths: - - 'sample-app/**' - - '.github/workflows/build-test.yml' - pull_request: - branches: [main] - workflow_dispatch: + branches: + - develop + - main + - working-advanced-anastasia jobs: - build-and-test: - name: Build and Test + build: runs-on: ubuntu-latest - + strategy: matrix: - node-version: [16.x, 18.x] - + node-version: [22.x] + steps: - - name: Checkout code + - name: Checkout Code uses: actions/checkout@v3 - - - name: Setup Node.js ${{ matrix.node-version }} + + - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - cache: 'npm' - cache-dependency-path: 'sample-app/package-lock.json' - - - name: Install dependencies - working-directory: ./sample-app - run: npm ci - - - name: Run linter - working-directory: ./sample-app - run: npm run lint - continue-on-error: true - - - name: Build application + + - name: Install Dependencies working-directory: ./sample-app - run: npm run build - - - name: Run tests + run: npm install + + - name: Run Tests working-directory: ./sample-app run: npm test - - - name: Upload coverage reports - if: matrix.node-version == '18.x' - uses: actions/upload-artifact@v3 + + - name: Create Artifact + run: echo "Build output" > output.txt + + - name: Upload Artifact + uses: actions/upload-artifact@v4 with: - name: coverage-report-${{ matrix.node-version }} - path: sample-app/coverage/ - retention-days: 30 - - - name: Check coverage - if: always() - working-directory: ./sample-app - run: | - if [ -f coverage/coverage-summary.json ]; then - echo "✅ Coverage report generated" - else - echo "⚠️ No coverage report found" - fi + name: build-output + path: output.txt - lint-check: - name: Lint Check + download-artifact: + needs: build runs-on: ubuntu-latest - + steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 + - name: Download Artifact + uses: actions/download-artifact@v4 with: - node-version: '18' - cache: 'npm' - cache-dependency-path: 'sample-app/package-lock.json' - - - working-directory: ./sample-app - run: npm ci - - - name: Run ESLint - working-directory: ./sample-app - run: npm run lint - continue-on-error: true + name: build-output - test-summary: - name: Test Summary - runs-on: ubuntu-latest - needs: [build-and-test] - if: always() - - steps: - - name: Print test results - run: | - echo "🎯 Test Run Summary" - echo "===================" - echo "✅ All tests completed" + - name: Show Artifact Content + run: cat output.txt \ No newline at end of file diff --git a/.github/workflows/conditional.yml b/.github/workflows/conditional.yml new file mode 100644 index 00000000..90a69b12 --- /dev/null +++ b/.github/workflows/conditional.yml @@ -0,0 +1,20 @@ +name: Conditional Workflow + +on: + push: + branches: + - develop + - main + - working-advanced-anastasia + +jobs: + conditional-job: + runs-on: ubuntu-latest + + steps: + - name: Always Run + run: echo "This step always runs" + + - name: Deploy (main only) + if: github.ref == 'refs/heads/main' + run: echo "Deploying to production..." \ No newline at end of file diff --git a/.github/workflows/custom.yml b/.github/workflows/custom.yml new file mode 100644 index 00000000..69e78a2d --- /dev/null +++ b/.github/workflows/custom.yml @@ -0,0 +1,46 @@ +name: Custom Workflow + +on: + push: + branches: + - develop + +jobs: + custom-job: + runs-on: ubuntu-latest + + env: + NODE_ENV: test + LOG_LEVEL: debug + + strategy: + matrix: + node-version: [16.x, 18.x, 20.x] + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Print Environment Variables + run: | + echo "Environment: $NODE_ENV" + echo "Log Level: $LOG_LEVEL" + + - name: Access Secret + env: + TEST_SECRET: ${{ secrets.TEST_SECRET }} + run: | + echo "Secret loaded successfully" + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Install Dependencies + working-directory: ./sample-app + run: npm install + + - name: Run Tests + working-directory: ./sample-app + run: npm test \ No newline at end of file diff --git a/.github/workflows/hello-world.yml b/.github/workflows/hello-world.yml index 376deaa8..245b4e88 100644 --- a/.github/workflows/hello-world.yml +++ b/.github/workflows/hello-world.yml @@ -1,5 +1,7 @@ name: Hello World Workflow +#Thanus31 + on: push: branches: [main, develop] diff --git a/README.md b/README.md index 2e74d1a8..fdbd86eb 100644 --- a/README.md +++ b/README.md @@ -608,4 +608,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file **Happy Learning!** 🎓 +Learning GitHub Actions 🚀 + + diff --git a/sample-app/README.md b/sample-app/README.md index dd6b4f4d..fe08eba7 100644 --- a/sample-app/README.md +++ b/sample-app/README.md @@ -154,4 +154,8 @@ The app includes a health check endpoint at `/health` which returns HTTP 200 whe --- +Updated sample app documentation + +GitHub Actions practice update + **Happy learning! 🎓**