|
| 1 | +Great! The syntax you used tells GitHub Actions to only run that workflow when a commit is made to the master branch. |
| 2 | + |
| 3 | +# Deploying to production |
| 4 | + |
| 5 | +Just like with the other workflow, we'll need to build our application and deploy to AWS using the same action as before because we are working with the same `Node.js` app. |
| 6 | + |
| 7 | +**Continuous delivery** is a concept that contains many behaviors and other, more specific concepts. One of those concepts is **test in production**. That can mean different things to different projects and different companies, and isn't a strict rule that says you are or aren't "doing CD". |
| 8 | + |
| 9 | +In our case, we can match our production environment to be exactly like our staging environment. This minimizes opportunities for surprises once we deploy to production. |
| 10 | + |
| 11 | +## Step 10: Complete the deployment to production workflow |
| 12 | + |
| 13 | +### :keyboard: Commit the steps to the production workflow that allow you to deploy on merge to master |
| 14 | + |
| 15 | +Add a `build` and `deploy` job to the workflow in this PR. It should look like the file below when you are finished. |
| 16 | + |
| 17 | +Note that not much has changed from our staging workflow, except for our trigger. |
| 18 | + |
| 19 | +```yml |
| 20 | +name: Production deployment |
| 21 | + |
| 22 | +on: |
| 23 | + push: |
| 24 | + branches: |
| 25 | + - master |
| 26 | + |
| 27 | +jobs: |
| 28 | + build: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v1 |
| 33 | + - name: npm install and build webpack |
| 34 | + run: | |
| 35 | + npm install |
| 36 | + npm run build |
| 37 | + - uses: actions/upload-artifact@master |
| 38 | + with: |
| 39 | + name: webpack artifacts |
| 40 | + path: public/ |
| 41 | + |
| 42 | + deploy: |
| 43 | + name: Deploy Node.js app to AWS |
| 44 | + needs: build |
| 45 | + runs-on: ubuntu-latest |
| 46 | + |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v1 |
| 49 | + |
| 50 | + - name: Download built artifact |
| 51 | + uses: actions/download-artifact@master |
| 52 | + with: |
| 53 | + name: webpack artifacts |
| 54 | + path: public |
| 55 | + |
| 56 | + - name: Deploy to AWS |
| 57 | + uses: docker://admiralawkbar/aws-nodejs:latest |
| 58 | + env: |
| 59 | + AWS_ACCESS_KEY: {% raw %}${{ secrets.AWS_ACCESS_KEY }}{% endraw %} |
| 60 | + AWS_SECRET_KEY: {% raw %}${{ secrets.AWS_SECRET_KEY }}{% endraw %} |
| 61 | +``` |
0 commit comments