diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..e0e8f93 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,61 @@ + +name: Calculator CI/CD Pipeline + +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Check Project Files + run: | + test -f index.html + test -f styles.css + test -f script.js + + - name: Check JavaScript Syntax + run: node --check script.js + + - name: Prepare Website Artifact + uses: actions/upload-pages-artifact@v3 + with: + path: . + + deploy: + if: github.event_name == 'push' + needs: build-and-test + runs-on: ubuntu-latest + + permissions: + pages: write + id-token: write + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Setup GitHub Pages + uses: actions/configure-pages@v5 + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4