ããããã®ãä½ãã¾ããã
è¡ã£ããã¨:
- ãªã³ã¯ãçæããã¸ã§ãã1ã¤çããã
- 綺éºãªè¡¨ç¤ºã¯Step Summaryæ©è½ (å¾è¿°) ã®åãåãã¦ãã
ã¸ã§ãå®è¡ç»é¢ããPull-Reqã«æ»ããã
GitHub Actionsã®ã¸ã§ãå®è¡ç»é¢ã«ã¯ããã®å®è¡å ã¨ãªã£ãPull Requestã¸ã®ãªã³ã¯ãåå¨ããªããããå°ã£ã¦ããã
ããããã·ãã¥ã¨ã¼ã·ã§ã³:
- Pull Requestãè¦ãã¨ã¸ã§ããã³ã±ã¦ãã
- æ§åãè¦ã«è¡ããã¡ã«å±¥æ´ãã©ãã©ãæ·±ããªã -- ã¸ã§ãç»é¢å ã§ã®é·ç§»ã¯ã©ãã©ããã¹ããªãç©ã¾ãã
- Pull Requestã«æ»ããªããªã£ã¦ãã¾ã
ãã®è©±ãååã«ããã¨ããå ±æã®åµã ã£ãããããã£ã¦é ããéè¦ãããããã ã¨ãããã¨ãå¤æãããã¾ãããæ¹æ³ãèãããã¨ã«ããã
çµæãGitHub Actionä¸ã§Pull-Reqã¸ã®ãªã³ã¯ãçæãã¦è¯ãæãã«URLã表示ãããã¨è©¦ã¿ã¦ããã¾ãã¾ãã¾ããã£ãã®ã§ã¡ã¢ã
以ä¸ã®3ã¤ããã¤ã³ãã
- GitHub Actionsãæä¾ããå¤æ°ãæ´»ç¨ããã°å Pull-Reqã¸ã®ãªã³ã¯ãæ§æã§ãã
push
ã¤ãã³ãã ã¨ç´æ¥Pull-Reqçªå·ãå¾ãããªãããgh
ã³ãã³ãã§ä»£æ¿ã§ãã$GITHUB_STEP_SUMMARY
ã«ãªãã¤ã¬ã¯ããããã¨ã§ãStep Summaryãåºåã§ãã
ã¾ãã¯å®æåãæ示ãããããããé ã«ä½ãããã®ãè¦ã¦ããã
name: CI on: - push - workflow_dispatch jobs: # Step Summaryã«Pull-Reqã¸ã®ãªã³ã¯ãåºåããããã®ã¸ã§ã1ã¤ãå ¨ã¦ããã£ã¦ãããã designate-pull-req: name: Designate Pull-req URL runs-on: ubuntu-latest steps: # ghã³ãã³ãã®ããã«å¿ è¦ - name: Checkout code uses: actions/checkout@v2 - name: Get Pull Request Number id: pr run: echo "::set-output name=pull_request_number::$(gh pr view --json number -q .number || echo "")" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Show URL run: echo Pull Request is ${{ github.server_url }}/${{ github.repository }}/pull/${{ steps.pr.outputs.pull_request_number }} # $GITHUB_STEP_SUMMARYã«æ¸ãè¾¼ãã¨ãstep summaryãçæã§ãã - name: Adding markdown run: echo '### [PR \#${{ steps.pr.outputs.pull_request_number }}](${{ github.server_url }}/${{ github.repository }}/pull/${{ steps.pr.outputs.pull_request_number }})' >> $GITHUB_STEP_SUMMARY # ç¥
- ã¸ã§ãå®è¡ç»é¢ããPull-Reqã«æ»ããã
- å Pull-Reqã¸ã®ãªã³ã¯ãæ§æãã
- on: push ã®å ´åãèãã
- Step Summaries ã«æ¸ãè¾¼ã
- ã¾ã¨ã
- åèæç®
å Pull-Reqã¸ã®ãªã³ã¯ãæ§æãã
ã¾ãã¸ã§ãã®ãã£ããã¨ãªã£ãPull-Reqã¸ã®URLãå¾ãªããã°ãªããªããGitHub Actionsã¯å®è¡ç°å¢ã«ããã¤ãã®å¤æ°ãæ³¨å ¥ãã¦ãããã®ã§ãPull-Reqæ å ±ãå¾ãã®ã¯å®¹æã ã
ç¹ã«ã¸ã§ããpull_request
ã¤ãã³ãã«ããã¯ããã¦å®è¡ããã¦ããå ´åã«ã¯é ä½ããªãã
echo ${{ github.server_url }}/${{ github.repository }}/pull/${{ github.event.number }}
Pull-Reqçªå·ã¯${{ github.event.number }}
ã«å
¥ã£ã¦ããã®ã§ããã£ãããªã³ã¯ãæ§æã§ããã
on: push
ã®å ´åãèãã
ã¨ãããåé
ã®æ段ã¯ãã¸ã§ããon: push
ã§å®è¡ããã¦ããå ´åã«ã¯ä½¿ããªãã${{ github.event.number }}
ã空ã«ãªã£ã¦ãã¾ãããã ã
ãã®ãã代æ¿çãç¨ãããgh
ã³ãã³ããç¨ããã°Pull-Reqçªå·ãå¾ããããããããå¯ä½ç¨ã¨ãã¦ããã®æ¹æ³ãç¨ããã¨workflow_dispatch
ã«ãã£ã¦å®è¡ããå ´åã«ãæ£ããPull-Reqçªå·ãå¾ãããã¡ãªãããããã
# ç¥ steps: - name: Checkout code uses: actions/checkout@v2 - name: Get Pull Request Number id: pr run: echo "::set-output name=pull_request_number::$(gh pr view --json number -q .number || echo "")" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Show URL run: echo Pull Request is ${{ github.server_url }}/${{ github.repository }}/pull/${{ steps.pr.outputs.pull_request_number }} # ç¥
ãã£ã¦ãããã¨ã¯3ã¤ã
- gitã使ã£ã¦æ å ±ãå¾ãªããã°ãªããªãã®ã§ãCheckoutãã
gh
ã³ãã³ãã«ããPull-Reqçªå·ãå¾ã¦ããããstepã®outputã«ãã- stepã®outputãå¼ã³åºãããªã³ã¯ãæ§æãã
ãããè¡ããã¨ã§ãå®è¡æã«Pull-Requestã¸ã®ãªã³ã¯ãechoãããããã«ãªã£ãã
Step Summaries ã«æ¸ãè¾¼ã
ãã¦ãããã ãã§ã¯æ¨æºåºåã«ãªã³ã¯ãåºãã ããªã®ã§ãã¾ã便å©ã§ã¯ãªããid:cohalz ããªã³ã¯ã表示ããããã®ä¾¿å©ãªæ¹æ³ãæãã¦ãããã
GitHub Actionã®ã¸ã§ãã¯ãStep (Job) Summaryã¨ããæ¦å¿µãæã£ã¦ãã¦ãåã¹ãããã®å®è¡çµæãªã©ã®æ å ±ãMarkdownã¨ãã¦è¡¨ç¤ºãããããã
Summaryãåºåããã«ã¯ã $GITHUB_STEP_SUMMARY
ã«markdownæååããªãã¤ã¬ã¯ããã¦æ¸ãè¾¼ãã°è¯ããã¡ãªã¿ã«ãStep Summaryã¯ã¸ã§ãå®è¡ç»é¢ã®Summaryã«ã¾ã¨ãã¦è¡¨ç¤ºãããã
# ç¥ - name: Adding markdown run: echo 'ããã«ä½ããã®æååãæ¸ãè¾¼ãã¨Summaryã«è¡¨ç¤ºããã' >> $GITHUB_STEP_SUMMARY # ç¥
ãããå®è¡ããã¨æ¬¡ã®ãããªçµæããããã:
ãã®æ©è½ã使ã£ã¦ãªã³ã¯ãMarkdownå½¢å¼ã§æ¸ãè¾¼ãã ã®ããåé ã«ç¤ºããyamlã§ããã
æçµçã«å®è¡çµæãã©ããªãããåæ²ãããã
ããã§ããè¿·ããªãã
ã¾ã¨ã
gh
ã³ãã³ããæ´»ç¨ãã¦Pull Requestçªå·ãåå¾ãããããç¨ãã¦Pull Requestã¸ã®ãªã³ã¯ãæ§æããStep Summaryæ©è½ã使ã£ã¦ãªã³ã¯ãåããããã示ããã¨ãã§ããããã«ãªã£ãã
ç¹ã«Step Summaryæ©è½ã¯ãªã³ã¯ã表示ãã以å¤ã«ãæ§ã ãªæ´»ç¨ãèããããã®ã§ãè¦ãã¦ããããã