In this lab you will use CI/CD workflows.
Duration: 15-20 minutes
References:
- About continuous integration
- Using a build matrix for your jobs
- Storing workflow data as artifacts
- About continuous deployment
- Using concurrency
- Open the workflow file ci-workflow.yml
- Edit the file and copy the following YAML content to replace the
strategy
of theci
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]
- In the
ci
job, before thedeploy-test
job, copy the following YAML content to use theupload-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
- In the
deploy-test
job, after thecheckout
action, copyt the following YAML content to use thedownload-artifact
action
- name: Download a single artifact
uses: actions/download-artifact@v2
with:
name: output-log-file
- Commit the changes into a new
feature/lab07
branch - 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.
- Once PR opened, go to
Actions
and see the details of your running workflow - Once all checks have passed, click on the button
Merge pull request
to complete the PR - Go to
Actions
and see the details of your running workflow
- Open the workflow file cd-workflow.yml
- 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
- Update the workflow to run on push events
on:
push:
branches: [main]
- Commit the changes into the
main
branch - Go to
Actions
and see the details of your running workflow