【发布时间】:2022-12-18 03:24:28
【问题描述】:
我正在使用 GitHub 操作来运行 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"
【问题讨论】:
-
repo
default分支上的工作流吗? -
不,不是。必须要默认吗?当我在脚本中出错时它会显示错误,因此看起来它正在运行
-
要出现在 Github UI 上,带有
dispatch_event触发器的工作流需要存在于默认分支yes上。 -
成功了,谢谢