728x90
반응형
Github actions act
자동 배포 과정도 테스트를 진행하면서 개발을 하게 되는데, 테스트를 해보기위해 계속해서 push 를 하거나 pull request 를 만드는 것은 비효율적이다. 이런 부분들을 자동화 하기위해서 act 를 사용한다.
act 는 Github actions 워크플로우를 로컬의 개발환경에서 실행할 수 있게 해주는 오픈소스 도구이다. act 는 도커를 사용하기 때문에 도커가 깔려 있어야 하며 아래의 장점들을 가지고 있다.
- 디버깅 : 푸시하면서 디버깅 할 필요 없음
- 빠른 반복 : 원격 실행을 기다릴 필요가 없음
install - macOS
brew install act
install - Windows
# Chocolatey
choco install act-cli
# Scoop
scoop install act
# Winget
winget install nektos.act
Example commands
# Command structure:
act [<event>] [options]
If no event name passed, will default to "on: push"
If actions handles only one event it will be used as default instead of "on: push"
# List all actions for all events:
act -l
# List the actions for a specific event:
act workflow_dispatch -l
# List the actions for a specific job:
act -j test -l
# Run the default (`push`) event:
act
# Run a specific event:
act pull_request
# Run a specific job:
act -j test
# Collect artifacts to the /tmp/artifacts folder:
act --artifact-server-path /tmp/artifacts
# Run a job in a specific workflow (useful if you have duplicate job names)
act -j lint -W .github/workflows/checks.yml
# Run in dry-run mode:
act -n
# Enable verbose-logging (can be used with any of the above commands)
act -v
act 는 실행을 job 단위로도 가능하고 event 단위로도 실행이 가능하다.
# act -l 로 실행 가능한 리스트를 확인한다.
(venv) kimminhyeok@Ivans-Mac dev_django_app % act -l
Stage Job ID Job name Workflow name Workflow file Events
0 build_push_to_ncp push to NCP container registry CD using Docker Image CD.yml push,workflow_dispatch
0 echo-event echo event lesson1 lesson1.yml workflow_dispatch
0 docker-build docker build lesson1 lesson1.yml workflow_dispatch
0 deployment deployment CD by git pull lesson2.yml workflow_dispatch
0 get-workflow-name echo workflow name resusable workflow lesson4.yml workflow_call
0 greeting greeting resusable workflow lesson4.yml workflow_call
0 call-workflow call-workflow call workflow lesson4_caller.yml workflow_dispatch
0 get-workflow-name echo workflow name call workflow lesson4_caller.yml workflow_dispatch
0 on-success on-success workflow run lesson5.yml workflow_run
0 on-failure on-failure workflow run lesson5.yml workflow_run
0 upload upload Upload PR data lesson5_up.yml pull_request
0 download download Use the PR data lesson5_use.yml workflow_run
0 job1 job1 output handling output_handling.yml workflow_dispatch
1 pull_from_ncp Connect to Server via SSH and pull from NCP CD using Docker Image CD.yml push,workflow_dispatch
1 docker-images docker images lesson1 lesson1.yml workflow_dispatch
1 job2 job2 output handling output_handling.yml workflow_dispatch
execution example
# .github/workflows 내에 있는 모든 워크플로우 실행
act
# 특정 워크플로우 실행 명령어
act workflow_dispatch --workflows .github/workflows/lesson1.yml -e event.json
728x90
반응형
'Dev. > Github Actions' 카테고리의 다른 글
[Cloud] Github Actions: Code develop for TEST (0) | 2023.08.29 |
---|---|
[Cloud] Github Actions: Concept of CI (0) | 2023.08.28 |
[Cloud] CD: Github Actions - workflow_run & Dependency (0) | 2023.08.23 |
[Cloud] CD: Github Actions - Mutiple workflow (0) | 2023.08.23 |
[Cloud] CD: Github Actions - 환경변수, docker-compose (0) | 2023.08.21 |
댓글