Skip to content
111 changes: 33 additions & 78 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -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

Comment on lines 10 to +13
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
Comment on lines +22 to 33

- 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
20 changes: 20 additions & 0 deletions .github/workflows/conditional.yml
Original file line number Diff line number Diff line change
@@ -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..."
46 changes: 46 additions & 0 deletions .github/workflows/custom.yml
Original file line number Diff line number Diff line change
@@ -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 }}
Comment on lines +29 to +31
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
Comment on lines +35 to +46
2 changes: 2 additions & 0 deletions .github/workflows/hello-world.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Hello World Workflow

#Thanus31

on:
push:
branches: [main, develop]
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -608,4 +608,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file

**Happy Learning!** πŸŽ“

Learning GitHub Actions πŸš€



4 changes: 4 additions & 0 deletions sample-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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! πŸŽ“**
Loading