From c954b68a2c29c1d1a65904bbafbadc1ed2a8a4fe Mon Sep 17 00:00:00 2001 From: Alfredo Perez Date: Thu, 2 Jan 2025 14:55:29 -0600 Subject: [PATCH] feat: add GitHub Actions workflow for deploying static content to GitHub Pages - Introduced a new GitHub Actions workflow in `deploy.yml` for building and deploying static content. - Configured the workflow to trigger on pushes to the `main` branch and allow manual execution. - Set up jobs for running unit tests and deploying to GitHub Pages, ensuring a streamlined CI/CD process. - Included steps for Node.js setup, dependency installation, unit testing, building the application, and deploying the built content. --- .github/workflows/deploy.yml | 59 ++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f7a3f2b --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,59 @@ +name: Build and deploy static content to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ['main'] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow one concurrent deployment +concurrency: + group: 'pages' + cancel-in-progress: true + +jobs: + unit-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Run unit tests + run: npm run test + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: [unit-tests] + steps: + - uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + - name: Build + run: npx nx run documentation:build --configuration=production + - name: Setup Pages + uses: actions/configure-pages@v4 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: 'dist/apps/ngx-dev-toolbar-demo/browser' + - name: Deploy to GitHub Pages + uses: actions/deploy-pages@v4