GitHub Actionsã§è¤æ°ã®workflowãé£æºããæã«ããã£ããããã
GitHub Actionsã§æãworkflowãçµãã£ããå¥ã®workflowãåãããã¿ãããªãã¨ããããããªã£ãæã«ã¡ã¾ã¡ã¾ããã£ãã®ã§ã¡ã¢ã¨ãã¦æ®ãã¾ãã
workflow_run
ã§å¼ã³åºãããworkflowã§åworkflowã®ã¹ãã¼ã¿ã¹ãåã
ããã¯ããã£ããã¨ã¨ããããããããã°è¯ããã¨ãã話ãªãã§ããã
on: workflow_run: workflows: - check types: - completed jobs: ...
ã¿ããã«æ¸ãã¦ãã㨠check
workflowãå®äºããæã«ãã®workflowãå¼ã³åºãããã®ã§ããããã®æ check
ã®æå¦ã¯é¢ä¿ç¡ãå¼ã³åºããã¾ãã
å¾ã£ã¦ãcheck
ãå®äºããæã«ã®ã¿å®è¡ãããæã«ã¯ä»¥ä¸ã®ããã«ã¹ãã¼ã¿ã¹ãã§ãã¯ãå
¥ããå¿
è¦ãããã¾ãã
on: workflow_run: workflows: - check types: - completed jobs: do_something: if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: ...
ref: Events that trigger workflows - GitHub Docs
ããã¯ããã¨ã㦠completed
typeã ããããªã㦠succeeded
ã failed
ã¿ãããªtypeã workflow_run
ã§æå®ã§ããã¨å¬ãããããªæ°ã¯ããã®ã§ãã......
workflow_run
ã¯default branchã«åå¨ãã¦ããªãã¨åããªã
Events that trigger workflows - GitHub Docs
Note: This event will only trigger a workflow run if the workflow file is on the default branch.
å
¬å¼ããã¥ã¡ã³ãã«ãã£ã¡ãç®ç«ã¤ããã«æ¸ãã¦ããï¼ï¼
workflowãæ´åãããã©ã³ãã§ä½æ¥ãã¦ã¦ããããããªãåããªããªããã¨æã£ã¦ããããããã話ã ã£ãã¨ãããªããdefault branchã« workflow_run
ã使ãworkflowãpushãã¦ãããªããã°é§ç®ã
workflow_run
ã§å¼ã³åºãããworkflowä¸ã§ã¯ github.ref_type
ã¯å¸¸ã« branch
ã«ãªã
1ã¤åã®è©±é¡ã«ãéããã¨ããã§ããã
Events that trigger workflows - GitHub Docs
ãã®ããã¥ã¡ã³ãã«ãããããã« `GITHUB_REF` ã¯default branchã¨ãªã£ã¦ãããã github.ref_type
ã¯å¸¸ã« branch
ã¨ãªãã¾ãã
on: workflow_run: workflows: - check types: - completed jobs: do_something: if: ${{ github.ref_type == 'tag' }} steps: ...
ä¸ã®ããã«æ¸ãã¦ããã¨ãä»®ã«å
ã®workflow (ãã®å ´å㯠check
) ãtagã®pushã«ãã£ã¦ããªã¬ã¼ããã¦ããã¨ãã¦ã github.ref_type
㯠branch
ã¨ãªããã絶対㫠do_something
ã¯å®è¡ããã¾ãããããã¯ã¡ãã£ã¨ããã£ã......
workflow_call
ã§å¼ã³åºãããworkflowããã¯repositoryã«ç»é²ããã¦ããsecretsãç´æ¥åç
§ã§ããªã
on: workflow_call: jobs: do_something: runs-on: "ubuntu-latest" steps: - env: PASSWORD: ${{ secrets.PASSWORD }} run: | echo ${{ env.PASSWORD }} ...
ä»åº¦ã¯ workflow_run
ã§ã¯ãªã workflow_call
ã®è©±é¡ããªããªã workflow_run
ã§ã¯ãtagãpushãããæã ããªããããããå®ç¾ã§ããªãã£ããã......
workflow_call
ã«ãããä»ã®workflowããæ示çã«å¼ã³åºãããworkflowã¯repositoryã«ç»é²ããã¦ããsecretsãç´æ¥åç
§ãããã¨ãã§ããªããããä¸è¨ã®echoã¯ä½ã表示ãã¾ããã
on: workflow_call: secrets: PASSWORD: required: true jobs: do_something: runs-on: "ubuntu-latest" steps: - env: PASSWORD: ${{ secrets.PASSWORD }} run: | echo ${{ env.PASSWORD }} ...
ä¸è¨ã®ããã« workflow_call.secrets
ã§åãåãå¤æ°ãæ示ãã¦ããã¦ã
call-workflow: uses: ./.github/workflows/next.yml secrets: PASSWORD: ${{ secrets.PASSWORD }}
ã®ãããªæãã§å¼ã³å ã®workflowããé©åã«æ¸¡ãã¦ãããå¿ è¦ãããã¾ãã
ref: Reusing workflows - GitHub Enterprise Cloud Docs
ã¨ããããã§ãããããç·åãããtagãpushããããªããã¤å
ã®workflow (ãã®å ´å㯠check
job) ãæåããæã«repoã«ç»é²ãããsecretsã渡ããªããå¥ã®workflowãå¼ã³åºããã¨ããå®ç¾©ãæ¸ãããæã¯å
ã®workflowã§ã¯
on: push: jobs: check: ... call-workflow: needs: [check] if: ${{ github.ref_type == 'tag' }} uses: ./.github/workflows/next.yml secrets: PASSWORD: ${{ secrets.PASSWORD }}
ã¨æ¸ãã¦ããã¤ã¤ãå¼ã°ããworkflowã§ã¯
on: workflow_call: secrets: PASSWORD: required: true jobs: do_something: ...
ã¨ãããµãã«æ¸ãã¦ããã°ç®çãæºè¶³ã§ãããã¨ããããã¾ããããããããããã£ã......