Set Up Workflow Actions and YAML
In this activity, the instructor will demonstrate how to create and configure a YAML file with GitHub Actions so that your CI/CD pipeline will trigger and run your unit test before deploying the lor-cicd-pipeline project via Netlify.
Instructions
- In the root of your project, create a
.github directory.
- Inside of
.github, create a directory called workflows.
mkdir ./.github/workflows
- Inside of
.github/workflows, create a file called push.yml.
touch ./.github/workflows/push.yml
- Inside of
workflows/push.yml, copy the following code:
# push.yml
# Name of workflow
name: Push workflow
# When workflow is triggered
on:
push:
branches:
- dev
- main
# Jobs to carry out
jobs:
deploy:
# Operating system to run job on
runs-on: ubuntu-latest
# Steps in job
steps:
# Get code from repo
- name: Checkout code
uses: actions/checkout@v1
# Install NodeJS
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
# Run npm install and build on our code
- run: npm install
- run: npm run build --if-present
# Run Test
- name: Run tests
run: npm run test
# Deploy to Netlify using our production secrets
- name: Deploy to netlify
uses: netlify/actions/cli@master
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
with:
args: deploy --dir=build --prod
secrets: '["NETLIFY_AUTH_TOKEN", "NETLIFY_SITE_ID"]'
© 2023 edX Boot Camps LLC. Confidential and Proprietary. All Rights Reserved.
Set Up Workflow Actions and YAML
In this activity, the instructor will demonstrate how to create and configure a
YAMLfile withGitHub Actionsso that your CI/CD pipeline will trigger and run your unit test before deploying thelor-cicd-pipelineproject via Netlify.Instructions
.githubdirectory.mkdir .github.github, create a directory calledworkflows.mkdir ./.github/workflows.github/workflows, create a file calledpush.yml.touch ./.github/workflows/push.ymlworkflows/push.yml, copy the following code:© 2023 edX Boot Camps LLC. Confidential and Proprietary. All Rights Reserved.