to see the site is working. You are now running the Linux version of NodeJS locally on Windows via WSL.
99 |
100 | ### Debug the Node Project with VS Code
101 | 1. While still in the Node+JS profile in Terminal, close the previous running instance of NodeJS if you haven't already. We're now going to start the same project using VS Code.
102 | 2. Navigate to the '`\projects\nodejs-shopping-cart` directory and type `code .` to open the project in VS Code.
103 | 3. This opens VS Code on Windows with a feature to debug the NodeJS project running in WSL.
104 | 4. In VS Code you can run the debugger and use breakpoints. You're using a Windows code editor/debugger for a project running the Linux NodeJS. Pretty cool!
105 |
106 | ## Customize Windows Terminal
107 |
108 | Let's make the Node+JS profile look more like Ubuntu. Using your Node+JS profile, update the properties below in the JSON. As you update your profile, the Terminal will automatically reflect your changes.
109 | 1. Set `"useAcrylic" : false,`
110 | 2. Set `"fontFace" : "Ubuntu Mono",`
111 | 3. Set `"fontSize" : 14,`
112 | 4. Set `"colorScheme" : "One Half Dark",`
113 | 5. Set `"cursorShape" : "filledBox",`
114 | 6. Add `"backgroundImage" : "ms-appdata:///roaming/ubuntu.jpg",`
115 | 7. Add `"backgroundImageOpacity" : 0.8,`
116 | 8. Add `"tabTitle" : "Ubuntu 18.04",`
117 | 9. Add `"suppressApplicationTitle" : true`
118 |
119 | After adding these changes, your profile should look like this:
120 | ```json
121 | {
122 | "guid" : "{c6eaf9f4-56a1-5fdc-b5cf-066e8a4b1e40}",
123 | "acrylicOpacity" : 0.5,
124 | "closeOnExit" : true,
125 | "colorScheme" : "One Half Dark",
126 | "commandline" : "wsl.exe -d Ubuntu-18.04",
127 | "cursorColor" : "#FFFFFF",
128 | "cursorShape" : "filledBox",
129 | "fontFace" : "Ubuntu Mono",
130 | "fontSize" : 14,
131 | "historySize" : 9001,
132 | "icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
133 | "name" : "My Node+JS Profile",
134 | "padding" : "4, 2, 4, 2",
135 | "snapOnInput" : true,
136 | "useAcrylic" : false,
137 | "backgroundImage" : "ms-appdata:///roaming/ubuntu.jpg",
138 | "backgroundImageOpacity" : 0.8,
139 | "tabTitle" : "Ubuntu 18.04",
140 | "suppressApplicationTitle" : true
141 | },
142 | ```
143 |
144 | Documentation for the settings in the profiles.json file can be found here: https://github.com/microsoft/terminal/blob/master/doc/cascadia/SettingsSchema.md
145 |
146 | ### Thank you
147 |
148 | Thank you for trying out Windows Terminal and WSL. Complete our [survey](https://aka.ms/js19) to register your completion!
149 |
150 | To learn more, please check out the following resources.
151 | - https://aka.ms/learnwsl
152 | - https://github.com/microsoft/terminal
153 | - https://code.visualstudio.com/docs/remote/wsl
154 |
--------------------------------------------------------------------------------
/3-github-actions/README.md:
--------------------------------------------------------------------------------
1 | # Deploying a Node.js Web App using GitHub Actions
2 |
3 | ## Overview
4 |
5 | **GitHub Actions** gives you the flexibility to build an automated software development lifecycle workflow. You can write individual tasks ("Actions") and combine them to create a custom workflow. Workflows are configurable automated processes that you can set up in your repository to build, test, package, release, or deploy any project on GitHub.
6 |
7 | With **GitHub Actions** you can build end-to-end continuous integration (CI) and continuous deployment (CD) capabilities directly in your repository.
8 |
9 | ### What’s covered in this lab
10 |
11 | In this lab, you will:
12 |
13 | 1. Create a web app on Azure using the App Service extension
14 | 1. Create a workflow with GitHub Actions to add CI/CD to your app
15 |
16 | ### Prerequisites
17 |
18 | 1. Your Windows machine should have Node.js LTS and Visual Studio Code.
19 |
20 | 1. You are using a GitHub account and an Azure account made for the purposes of this lab. These have been already logged into from your machine and the account info is saved.
21 |
22 | ### Setting up the GitHub repo
23 |
24 | 1. Navigate to the [example app repository](https://github.com/fiveisprime/Useful-Website).
25 |
26 | 1. Click the "Fork" button in the upper-right hand corner of the repository. From there, click the green "Clone" button and copy the URL.
27 |
28 | 
29 |
30 | ## Create an Azure App Service web app
31 |
32 | Create the App Service web app that you'l deploy to from GitHub.
33 |
34 | 1. Click on the Azure icon in the sidebar.
35 |
36 | 
37 |
38 | 1) Click on the `+` icon to create a new app service under the **VSCode GitHub Universe HOL** subscription.
39 |
40 | 
41 |
42 | 1. Give your webapp a unique name (we recommend calling it **YOUR_NAME-jsinteractive** )
43 |
44 | 1. Select **Linux** as your OS and **Node.js LTS** as your runtime.
45 |
46 | 1. It will take a minute or two to create the app. Once it's done, you'll get a prompt to browse to your new site. Click on "View output" and open the link to your site.
47 |
48 | > Note: If creation of the app is taking a bit longer than you expect, call one of the proctors and we'll switch you to an already created app
49 |
50 | 1. The page you browse to will be the default site you see, since you haven't yet deployed anything to the site.
51 |
52 | 
53 |
54 | ## Set up CI/CD with GitHub Actions
55 |
56 | Use GitHub actions to automate the deployment workflow for this web app.
57 |
58 | 1. Inside the App Service extension, right click on the name of your app service and choose "Open in Portal".
59 |
60 | 
61 |
62 | 1. From the Overview page, click on "Get publish profile". A publish profile is a kind of deployment credential, useful when you don't own the Azure subscription.
63 |
64 | 
65 |
66 | 1. Open the settings file you just downloaded in VS Code and copy the contents of the file.
67 |
68 | 1. Add the publish profile as a secret associated with this repo. On the GitHub repository, click on the "Settings" tab.
69 |
70 | 
71 |
72 | 1) Go to "Secrets". Create a new secret and call it "AZURE_WEBAPP_PUBLISH_PROFILE". Paste the contents from the settings file.
73 |
74 | 
75 |
76 | 1. Navigate to the Actions tab in the repo to find the **Deploy Node.js to Azure Web App** template and select "Set up this workflow".
77 |
78 | 
79 |
80 | 1. Update the `env` object, set `AZURE_WEBAPP_NAME` to the name of your app.
81 |
82 |
83 | ```yml
84 | env:
85 | AZURE_WEBAPP_NAME: YOUR_NAME-jsinteractive
86 | ```
87 |
88 | 
89 |
90 | 1. Once you're done, click on "Start commit". Fill in the text box with a commit message, and then click the "Commit change" button, which will trigger the workflow.
91 |
92 | 1. While the Action is being queued, let's get into the details of what this workflow is actually doing. Go to the `.github/workflows/azure.yml` file to follow along.
93 |
94 | - **Workflow Triggers (line 11)**: Your workflow is set up to run on "push" events to the branch
95 |
96 | ```yaml
97 | on:
98 | push:
99 | branches:
100 | - master
101 | ```
102 |
103 | For more information, see [Events that trigger workflows](https://help.github.com/articles/events-that-trigger-workflows).
104 |
105 | - **Running your jobs on hosted runners (line 21):** GitHub Actions provides hosted runners for Linux, Windows, and macOS. We specify the hosted runner in our workflow as below.
106 |
107 | ```yaml
108 | jobs:
109 | build-and-deploy:
110 | name: Build and Deploy
111 | runs-on: ubuntu-latest
112 | ```
113 |
114 | - **Using an action (line 26)**: Actions are reusable units of code that can be built and distributed by anyone on GitHub. To use an action, you must specify the repository that contains the action. We are also specifying the version of Node.js.
115 |
116 | ```yaml
117 | - uses: actions/checkout@master
118 | - name: Use Node.js ${{ env.NODE_VERSION }}
119 | uses: actions/setup-node@v1
120 | with:
121 | node-version: ${{ env.NODE_VERSION }}
122 | ```
123 |
124 | - **Running a command (line 31)**: You can run commands on the job's virtual machine. This action is running the npm commands below to install the dependencies, build the application, and run the tests.
125 |
126 | ```yaml
127 | - name: npm install, build, and test
128 | run: |
129 | # Build and test the project, then
130 | # deploy to Azure Web App.
131 | npm install
132 | npm run build --if-present
133 | npm run test --if-present
134 | ```
135 |
136 | > For workflow syntax for GitHub Actions see [here](https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions)
137 |
138 | 1. You can go back to the Actions tab, click on your workflow, and see that the workflow is queued or being deployed. Wait for the job to complete successfully before going back to your website.
139 |
140 | 
141 |
142 | ## Test out your app!
143 |
144 | 1. Back in VS Code, go to the App Service extension, and right click on your app service and click on "Browse Website" to see your site running.
145 |
146 | 1. Switch back to GitHub to test the GitHub Actions workflow you just made. Edit `views/index.hbs` using the GitHub editor and add the following lines of code on line 11
147 |
148 | ```html
149 |
150 |
Press the button!
151 |
152 | ```
153 |
154 | 
155 |
156 | 1) Go back to the Actions tab and you can watch the build finishing up. Once you see all the green check marks, go to Edge and reload your website!
157 |
--------------------------------------------------------------------------------