From f44a25d39e88a1d04093037f783fd942ad517da9 Mon Sep 17 00:00:00 2001 From: Peter Juma <30427827+peterjuma@users.noreply.github.com> Date: Thu, 9 May 2024 16:08:13 +0300 Subject: [PATCH] Create build_deploy.yml --- .github/workflows/build_deploy.yml | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/build_deploy.yml diff --git a/.github/workflows/build_deploy.yml b/.github/workflows/build_deploy.yml new file mode 100644 index 00000000..811fbffd --- /dev/null +++ b/.github/workflows/build_deploy.yml @@ -0,0 +1,47 @@ +name: Build and Deploy React App to GitHub Pages + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + outputs: + page_url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '16' # Adjust this to the Node.js version your project requires + + - name: Install Dependencies + run: npm install + + - name: Build React App + run: npm run build + # Ensure your project builds into the 'build' directory + + deploy: + runs-on: ubuntu-latest + needs: build + +# Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + environment: + name: github-pages + url: ${{ needs.build.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4