cd ~/Desktop
npx create-react-app my-app
cd my-app
npm start
git remote add origin https://github.com/dmarcs/my-app.git
git branch -M master
git push -u origin master
cd ~/Desktop/my-app
A quick way to copy the content is by entering this into Terminal (replace your app name with reactapptutorial)
pbcopy < ~/Downloads/reactapptutorial.PublishSettings
- name: add process.json
run: |
echo '{ script: "serve", env: { PM2_SERVE_SPA: "true", PM2_SERVE_HOMEPAGE: "/index.html" } }' >> build/process.json
This is needed because Azure App Services assumes you’re not going to run a SPA (single-page application).
Here’s the yaml file after changes
on: push
env:
AZURE_WEBAPP_NAME: reactapptutorial # set this to your application's name
AZURE_WEBAPP_PACKAGE_PATH: 'build' # set this to the path to your web app project, defaults to the repository root
NODE_VERSION: '10.x' # set this to the node version to use
jobs:
build-and-deploy:
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: npm install, build, and test
run: |
# Build and test the project, then
# deploy to Azure Web App.
npm install
npm run build --if-present
npm run test --if-present
- name: add process.json
run: |
echo '{ script: "serve", env: { PM2_SERVE_SPA: "true", PM2_SERVE_HOMEPAGE: "/index.html" } }' >> build/process.json
- name: 'Deploy to Azure WebApp'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
git pull
Now every time you push to this repo, the public website will be updated