This repo demostrates how you can deploy a front-end application from any git branch. You might need such behavior to view/test your PR's before merging to main branch.
Currently this application is available at http://devops2020demo.s3-website.eu-central-1.amazonaws.com
- Create React App was used to create an application
- {JSON} Placeholder was used as a fake REST API
- CircleCI was used as a CI/CD platform
- AWS S3 was used as a static website hosting
- Create a branch
<branch_name>frommaster - Checkout to newly created branch and make any changes, for example change title in
/public/index.html(feel free to change any file inside/srcfolder) - Add
.auto-deployfile to root (next topackage.json). Yes it's an empty file with no extention - Commit and push changes to GitHub.
- Head over to CircleCI dashboard and wait untill
autodeployjob finishes. It will automatically create a folder (with the same name as your<branch_name>) and upload built project there. - Navigate to
http://devops2020demo.s3-website.eu-central-1.amazonaws.com/autodeploy/<branch_name>- enjoy changes! 🥳
You can notice that GitHub doesn't allow PR to be merged to master with .auto-deploy file in it - see this example PR. The reason is that ensure_autodeploy_file_absence job marked as required and it will always fail if you include .auto-deploy file to your PR. As you can guess you'll need to remove .auto-deploy file from PR, this will also remove appropriate folder from AWS S3.