Skip to content

Latest commit

 

History

History
67 lines (62 loc) · 2.76 KB

lab07.md

File metadata and controls

67 lines (62 loc) · 2.76 KB

7 - CI/CD

In this lab you will use CI/CD workflows.

Duration: 15-20 minutes

References:

7.1 Update the CI workflow

  1. Open the workflow file ci-workflow.yml
  2. Edit the file and copy the following YAML content to replace the strategy of the ci job:
    strategy:
      # Cancel all matrix jobs if one of them fails
      fail-fast: true
      matrix:
        # our matrix for testing across node versions and OSs
        node-version: [12, 14, 16]
        os: [macos-latest, windows-latest, ubuntu-latest]
  1. In the ci job, before the deploy-test job, copy the following YAML content to use the upload-artifact action:
      - shell: bash
        run: |
          echo 'Test upload artifact' > output.log
      - name: Upload output file
        uses: actions/upload-artifact@v2
        with:
          name: output-log-file
          path: output.log
  1. In the deploy-test job, after the checkout action, copyt the following YAML content to use the download-artifact action
      - name: Download a single artifact
        uses: actions/download-artifact@v2
        with:
          name: output-log-file
  1. Commit the changes into a new feature/lab07 branch
  2. Open a new pull request from Pull requests

Make sure it is your repository pull request to not propose changes to the upstream repository. From the drop-down list choose the base repository to be yours.

  1. Once PR opened, go to Actions and see the details of your running workflow
  2. Once all checks have passed, click on the button Merge pull request to complete the PR
  3. Go to Actions and see the details of your running workflow

7.2 Update the CD workflow

  1. Open the workflow file cd-workflow.yml
  2. Edit the file and copy the following YAML content before the Deploy to production step:
    - name: Download artifact from build job
      uses: actions/download-artifact@v2
      with:
        name: node-app
  1. Update the workflow to run on push events
on:
  push:
     branches: [main]
  1. Commit the changes into the main branch
  2. Go to Actions and see the details of your running workflow