我有一个基于 Ionic Angular 的 PWA 项目。我想使用 GitHub Actions,这样当我推送更改时,我的项目就会在 Google Firebase 托管上构建和部署。
在准备好的package.json中,规范为"build-prod": "ionic build --prod".
在我的main.yml文件中,我指定了步骤:
- name: Checkout Repo
uses: actions/checkout@master
- name: Install Dependencies
run: npm install
- name: Build
run: npm run build-prod
Run Code Online (Sandbox Code Playgroud)
安装依赖项步骤进展顺利。但是,GitHub Actions 在构建步骤中显示错误:
Run npm run build-prod
> my-project@0.0.1 build-prod /home/runner/work/my-project/my-project
> ionic build --prod
sh: 1: ionic: not found
Run Code Online (Sandbox Code Playgroud)
据我了解,原因很简单,GitHub Actions 不知道ionic是什么。但是,当我尝试使用
- name: Build
run: npm run build
Run Code Online (Sandbox Code Playgroud)
默认情况下使用:ng build …
在 GitHub 存储库中,我有两个单独的 GitHub Actions 工作流程:
github/workflows/pr.yml只是构建和测试
name: Pull request workflow
on: pull_request
Run Code Online (Sandbox Code Playgroud)
并github/workflows/push.yml构建、测试和部署
name: Push workflow
on: push
Run Code Online (Sandbox Code Playgroud)
创建拉取请求会触发这两个工作流程。
是否无法将它们分开或者我在这里缺少什么?
我的android项目使用gradle属性中的一些键~/.gradle/gradle.properties。git 故意忽略了这一点。有没有办法让 github actions 访问这些属性?
因此,我为我的 Android 应用程序开发了一些测试,我需要使用 github actions 工作流程来运行测试。这是我的 .yml 文件,但我不知道如何运行测试(并获取其日志):
name: Java CI with Gradle
on:
push:
pull_request:
branches: Features
jobs:
test:
name: Run Unit Tests
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Unit tests
run: bash ./gradlew test --stacktrace
- name: Unit tests results
uses: actions/upload-artifact@v1
with:
name: unit-tests-results
path: ./app
Run Code Online (Sandbox Code Playgroud)
我不确定如何运行所有应用程序,然后运行所有测试,有人可以给我提示吗?我搜索了整个互联网,发现了这段代码,但它不起作用。我的工件是整个应用程序本身测试是:
1.SignUpTest.java
2.SignInTest.java
3.AddToCart.java
在我的 Github 工作流程中,我正在检查两个存储库。随后,我将工作流程存储库“repoA”的两个目录与存储库“repoB”合并。当推送到 repoB 时,出现错误:
From ../repoA
* [new branch] master -> workspace/master
Automatic merge went well; stopped before committing as requested
[master cbd72fe] Update
To https://github.com/username/repoB.git
! [remote rejected] master -> master (shallow update not allowed)
error: failed to push some refs to 'https://username@github.com/username/repoB.git'
##[error]Process completed with exit code 1.
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我的仓库很浅以及如何修复它。Github 工作流程文件:
name: test
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout current repo
uses: actions/checkout@v2
with:
path: repoA
- name: Checkout other repo
uses: actions/checkout@v2
with: …Run Code Online (Sandbox Code Playgroud) 我已经使用 GitHub Actions 自托管运行器说明设置了 CI 构建服务器。一切正常,直到达到以下指令:
sudo xcode-select -switch /Applications/Xcode_11.5.app
Run Code Online (Sandbox Code Playgroud)
它要求我在 macOS 终端内输入密码。如果我每次运行该作业时都必须输入密码,那么这就违背了构建服务器的目的。我尝试将运行程序配置为服务,但是当我这样做时,作业完全失败,因为它需要终端来询问密码。
有没有办法设置密码,让跑步者不再每次都询问我?
我需要使用 Github Actions 将分支名称作为参数传递给 .ps1 脚本。Github 操作部分:
runs-on: windows-latest
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
steps:
- name: Extract branch name
shell: bash
run: echo "${GITHUB_REF}"
id: extract_branch
- uses: actions/checkout@v1
- name: Run a one-line script
run: .\Scripts\my_script.ps1 -branch_name ${GITHUB_REF}
shell: powershell
Run Code Online (Sandbox Code Playgroud)
.ps1部分:
##############################################
#Script Title: Download File PowerShell Tool
#Script File Name: Download-File.ps1
#Author: Ron Ratzlaff
#Date Created: 4/21/2016
##############################################
#Requires -Version 3.0
param($branch_name)
"Current branch"
$branch = git rev-parse --abbrev-ref HEAD
"$branch"
"${branch}"
"${GITHUB_REF}"
"$GITHUB_REF"
"$branch_name"
"{branch_name}"
Write-Host $branch_name
Run Code Online (Sandbox Code Playgroud)
我显示了 …
我正在使用 Github actions 构建 Android apk,并且我需要使用 Android 签名密钥以便在发布之前对其进行签名。
为此,我使用此处描述的GPG 技术将发布密钥加密为 base64 字符串,并将其用作 Github 操作中的秘密。
然后,在我的工作流程中,我使用 GPG 将其解密回密钥文件中。
然而,这个过程在我的 Mac 上运行良好,但在 Github 操作中却失败了。
运行这个
- name: Decode keystore file
run: |
echo "${{ secrets.KEY_STORE }}" > release.keystore.asc
gpg -d --passphrase "${{ secrets.KEY_STORE_PASSPHRASE }}" --batch release.keystore.asc > signing-key.jks
Run Code Online (Sandbox Code Playgroud)
结果是这样的
gpg: directory '/home/runner/.gnupg' created
gpg: keybox '/home/runner/.gnupg/pubring.kbx' created
gpg: no valid OpenPGP data found.
gpg: decrypt_message failed: Unknown system error
##[error]Process completed with exit code 2.
Run Code Online (Sandbox Code Playgroud)
在使用 GPG 之前运行sudo apt-get …
作业中的一个步骤需要设置环境变量。类似下面的代码示例可以通过 github actions 实现吗?
例子:
- name: Do Something
env:
NEW_VAR: $EXISTING_VAR/subdir
run: |
echo $NEW_VAR
Run Code Online (Sandbox Code Playgroud)
我知道,我可以直接使用环境变量,但最好通过连接旧的环境变量来构造新的环境变量。
还有${{ env.EXISTING_VAR }},但看起来这个表达式没有被求值。
我正在尝试实现 Github Actions,但无法运行 Rails 命令。
运行时bundle exec rake或bundle exec rails db:create在 github 工作流程中引发错误。
Run bundle exec rake rails db:setup
bundle exec rake rails db:setup
shell: /bin/bash -e {0}
env:
PATH: /home/runner/.rubies/ruby-2.6.5/bin:/usr/share/rust/.cargo/bin:/home/runner/.config/composer/vendor/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin
RAILS_ENV: test
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432
RUBYOPT: -W:no-deprecated -W:no-experimental
/home/runner/.rubies/ruby-2.6.5/bin/ruby: invalid option -: (-h will show valid options) (RuntimeError)
##[error]Process completed with exit code 1.
Run Code Online (Sandbox Code Playgroud)
这是我的 ruby.yml 文件:
name: Ruby
on:
push:
branches: [ master ]
pull_request:
branches: [ master ] …Run Code Online (Sandbox Code Playgroud) github-actions ×10
github ×4
android ×2
angular ×1
arguments ×1
build.gradle ×1
github-api ×1
gnupg ×1
gradle ×1
java ×1
macos ×1
powershell ×1
ruby ×1
sudo ×1
workflow ×1