首页 > 解决方案 > 如何链接 github 操作工作流

问题描述

我是 github 操作的新手,我写了 3 个工作流。我的用例如下。

我不确定如何链接所有这 3 个工作流程以实现上述结果。有人可以帮我吗。

工作流程-1:

name: "Terraform Pull Request Builder" 
on: [push,pull_request]
jobs:   
  validate:
    name: Validate terraform configuration
    runs-on: ubuntu-latest
    steps:
      - name: Checkout the code
        uses: actions/checkout@v2
      - uses: hashicorp/setup-terraform@v1
        with:
          terraform_version: 0.12.28

      - uses: aws-actions/configure-aws-credentials@v1  #https://github.com/aws-actions/configure-aws-credentials#usage
        id: assume
        with:
          aws-region: us-east-1
          role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} 

      - name: Terraform fmt
        id: fmt
        run: terraform fmt -check
        continue-on-error: true
       .... more code to terraform plan and commenting the output back on the PR

工作流程-2

name: Slash Command Dispatch
on:
  issue_comment:
    types: [created, deleted]

jobs:
  slashCommandDispatch:
    runs-on: ubuntu-latest
    steps:
      - name: Slash Command Dispatch
        uses: peter-evans/slash-command-dispatch@v2
        id: comment
        with:
          token: ${{ secrets.PAT }}
          reaction-token: ${{ secrets.PAT }}
          commands: |
            deploy

工作流程-3

name: Reaction
on:
  repository_dispatch:
    types: [deploy-command]
jobs:
  helloWorld:
    runs-on: ubuntu-latest
    steps:
      - name: Add reaction
        uses: peter-evans/create-or-update-comment@v1
        with:
         token: ${{ secrets.PAT }}
         issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
         repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
         comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
         reaction-type: hooray  

标签: githubgithub-actions

解决方案


推荐阅读