GiitHub Actions를 사용하여 GiitHub Issue를 계산기로 사용

3020 단어 GitHub Actionstech
GiitHub Actions를 능숙하게 사용하면 GiitHub Issue를 계산기로 사용할 수 있습니다.
다음은 Issue를 사용한 계산1 + 2 * (3 + 4) / 5 = 3.8입니다.

이것을 실현하기 위해 아래의 워크플로우를 준비하면 됩니다.
.github/workflows/dentaku.yml
name: Dentaku

on:
  issues:
    types: opened

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      
      - id: calculate
        run: |
          ans=$(echo "${{ github.event.issue.title }}" | bc -l)
          echo "::set-output name=ANS::${ans}"
      
      - uses: actions-ecosystem/action-create-comment@v1
        with:
          github_token: ${{ secrets.github_token }}
          body: |
            ${{ steps.calculate.outputs.ANS }}
요점은 bc 명령를 사용하여 문자열에서 계산하고workflow 기능set-output 명령을 사용하여 전역에서 결과를 사용하는 것이다.
일반적인 계산기가 지쳤을 때 사용해 보세요.

좋은 웹페이지 즐겨찾기