# Build and Deployment Procedure

* Search all source for console.log statements; comment out any that are not intended to inform a user or administrator
* Run and test the app locally using:
  * `cd apps/rockmtn-platform`
  * `npm run dev`
* **Conformance** - While it is not strictly required, you should run the linter and conform to any rule recommendations before commiting new code.
  * `npx next lint`
  * Note: `npx next lint` is also run automatically by the `npm run build` command in the next step, so you don’t necessarily have to execute that step independendtly.
* Build, run, and test the app in Production mode:
  * `npm run build` - Builds the app for production
  * `npm start` - Runs the built app in production mode.
* Ensure that the version number in `./package.json` has been incremented since the last push to the `preview` branch.
  * Since pushing to the `preview` branch automatically deploys to <https://codyburleson.cloud> (CLOUD, instead of COM), you can verify the last pushed vesion by looking in the site footer.
* Push changes to the `preview` branch (or any unique branch that is NOT the `main` branch).
  * This will push the branch to Vercel where you MUST then QA test in that scenario.
  * Again, remember that pushing to the `preview` branch automatically deploys to <https://codyburleson.cloud> (CLOUD, instead of COM)
  * If all tests are successful…
* Navigate to the [project repo on GitHub](https://github.com/codyburleson/rockmountain) in your web browser and issue a pull request to merge the `preview` branch into the `main` (Production) branch.
  * If all checks pass and there are no merge conflicts with the base branch, choose to “Squash and merge” (all commits from the preview branch will be combined into one commit in the base branch).
  * You should see a message in GitHub similar to the following: “Pull request successfully merged and closed. You’re all set—the preview branch can be safely deleted.”
  * However, you MUST NOT delete the `preview` branch. You MAY delete any temporary branch other than `preview`, however.
* Navigate to the live Production app, verify successful deployment by the version number in the footer and do any spot checks you feel may be necessary.
* It is highly recommended to watch the Function logs on Vercel for a little while.
  * While the view is open, GET requests, server-side console.log() statements, and errors will log here.
  * Note that logs are NOT persisted unless you setup a Log Drain (e.g. integration to cloud-based log storage).
