从 GitHub Actions 手动触发工作流程

问题描述 投票:0回答:1

我正在使用 GitHub Actions 运行 Android 应用程序项目的 CI。 我有一个运行良好的工作流程。它在 PR 上运行,运行测试并构建应用程序。

我重用了工作流程代码来构建一个新的工作流程代码,并将其放入同一文件夹中的不同

yml
文件中。

不同之处在于,此工作流程有一个

workflow_dispatch
作为事件。它还需要一个输入。它运行测试,然后在 Goolge Play 或 Firebase 上发布构建版本。现在我只是使用一些
echo
来记录正在发生的事情。

阅读文档时,我希望看到一个从 GitHub UI 手动触发工作流程的按钮。

当我单击“操作”选项卡时,我看不到工作流程,因此我看不到该按钮。 如果我犯了一个错误,例如我删除了所有作业,那么我会看到工作流程,因为我失败了

run
。反正按钮是不可见的。

name: Publish On CI

on:
  workflow_dispatch:
    inputs:
      publish:
        description: 'Choose where you want to publish the build'
        required: true
        default: AppTester
        type: choice
        options:
          - GooglePlay
          - AppTester
          - Both

env:
  ANDROID_KEYS_FOLDER: ..

jobs:
  publish:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
      - name: decode keys
        run: echo "${{ secrets.APP_PROPERTIES_BASE64 }}" | base64 > app.properties
          echo "${{ secrets.APP_RELEASE_BASE64 }}" | base64 > app-release
      - name: set up JDK 11
        uses: actions/setup-java@v3
        with:
          java-version: '11'
          distribution: 'temurin'
          cache: gradle

      - name: Grant execute permission for gradlew
        run: chmod +x gradlew
      - name: Run Unit test
        run: ./gradlew testStagingUnitTest
      - name: Build
        run: ./gradlew :app:assembleStaging
      - name: Publish on Google Play if required
        if: inputs.publish == 'GooglePlay'
        run: echo "Publishing on Google Play"
      - name: Publish on Firebase if required
        if: inputs.publish == 'AppTester'
        run: echo "Publishing on Firebase"
      - name: Publish on Google Play and Firebase if required
        if: inputs.publish == 'Both'
        run: echo "Publishing on Google Play and Firebase"
android github-actions
1个回答
7
投票

具有

workflow_dispatch
触发器的工作流程需要存在于 存储库默认分支 上才能显示在 Github 用户界面
Actions
选项卡上。

© www.soinside.com 2019 - 2024. All rights reserved.