GitHub Actions: Basics
In this post I will show you how you can pass artifacts between in gitlab CI.
What is GitHub Actions?
GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline with GitHub.
You can configure a GitHub Actions workflow to be triggered when an event occurs in your repository, such as a pull request being opened or an issue being created. Your workflow contains one or more jobs which can run in sequential order or in parallel. Each job will run inside its own virtual machine runner, or inside a container, and has one or more steps that either run a script that you define or run an action, which is a reusable extension that can simplify your workflow. You can find the available action in the GitHub marketplace
Create an example workflow
GitHub Actions uses YAML syntax to define the workflow. Each workflow is stored as a separate YAML file in your code repository, in a directory named .github/workflows
.
mkdir .github/workflows
nano .github/workflows/cicd.yaml
---
name: learn-github-actions
# trigger
on:
push:
jobs:
# job definition. You can create multiple jobs
build:
name: 'Build'
runs-on: ubuntu-latest
steps:
- name: "checkout code"
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '14'
- run: npm install -g bats
- run: bats -v
# share between jobs
- uses: actions/upload-artifact@master
with:
name: data
path: dist/
deploy-dev:
name: "Deploy To Dev"
# add job called build as dependency
needs: build
steps:
# download from previous job
- uses: actions/download-artifact@master
with:
name: data
path: dist/
If you created the file, you need to commit and push to the github repository. Then it will run automatically each time someone pushes a change to the repository. When your workflow is triggered, a workflow run is created that executes the workflow. After a workflow run has started, you can see a visualization graph of the run’s progress and view each step’s activity on GitHub. To find this click Actions in the repository.