github actions

uses 로 action 사용해 보기

wefree 2022. 2. 26. 21:59

문제

https://github.com/actions/hello-world-javascript-action 에 만들어져 있는 "actions/hello-world-javascript-action" 를 사용해보자. README 문서를 보면

  1. Input 으로 who-to-greet 를 받는다.
  2. Output 으로 time 변수에 출력시간을 저장해 준다.

 

코드

name: Actions Workflow

on:
  - push

jobs:
  run-github-actions:
    runs-on: ubuntu-latest
    steps:
      - name: Simple JS Action
        id: greet
        uses: actions/hello-world-javascript-action@v1.1
        with:
          who-to-greet: windbird123
      - name: Log Greeting Time
        run: echo "${{ steps.greet.outputs.time }}"

 

설명

  • https://github.com/actions/hello-world-javascript-action/releases 페이지를 보면 v1.1 이 release 되어 있다. 그래서 actions/hello-world-javascript-action 의 뒤에 사용할 버전 @v1.1 을 붙여주었다. release 버전 뿐만 아니라 branch 혹은 commit 버전을 사용하는 것도 가능하다.
  • step 항목에 id: greet 를 넣었다. 이후 step 에서 id: greet 의 Output 를 참조하는데 사용할 수 있다.
  • Input 을 입력 받을 수 있도록 with 를 사용해 who-to-greet 값을 지정해 주었다.
  • github actions marketplace 에서 필요한 action 을 찾아 활용할 수 있다.

 

실행 결과

push 를 하면 자동으로 실행되는데, id: greet step 메시지를 살펴보면 ouput name 이 'time' 으로 설정된 것을 볼 수 있다.

 

참고: https://www.udemy.com/course/github-actions