我使用 Github Actions 使用 Maven 自动构建和测试我的项目,但在测试过程中失败了。这是错误消息:
java.lang.RuntimeException:java.lang.UnsupportedOperationException:无法打开DISPLAY
由于我的测试使用的是 UI,听起来我需要启用图形界面,但我不知道如何做到这一点。我正在使用JavaFX13。您可以在github 页面上看到完整的构建日志。
这是我使用的脚本:
name: Maven build
on:
pull_request:
branches: master
push:
branches: master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 13
uses: actions/setup-java@v1
with:
java-version: 13
- name: Build with Maven
run: mvn -B package --file pom.xml
Run Code Online (Sandbox Code Playgroud)
我通过使用以下方法在Travis CI上工作:
services:
- xvfb
Run Code Online (Sandbox Code Playgroud)
和
before_script:
- "export DISPLAY=:99.0"
Run Code Online (Sandbox Code Playgroud)
但我找不到任何可以让它与 Github 操作一起工作的东西。我缺少什么?
为了将新任务部署到 ECS,我使用amazon-ecs-render-task-definition GitHub 操作。此操作接收 task-definition.json 作为参数。这个 JSON 包含我不想推送的秘密,有没有办法向这个 JSON 注入一些参数?也许来自 aws Secret Manager?
例如 -任务定义.json
{
"containerDefinitions": [
{
"name": "wordpress",
"links": [
"mysql"
],
"image": "wordpress",
"essential": true,
"portMappings": [
{
"containerPort": 80,
"hostPort": 80
}
],
"memory": 500,
"cpu": 10
},
{
"environment": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": ****"password"**** // ITS A SECRET!
}
],
"name": "mysql",
"image": "mysql",
"cpu": 10,
"memory": 500,
"essential": true
}],
"family": "hello_world" }
Run Code Online (Sandbox Code Playgroud) 这是项目结构:
- parent/
|- .github/workflows/
|- frontend/
|- ...
Run Code Online (Sandbox Code Playgroud)
这是工作流程中的 .yml 文件:
name: CI
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: "12.x"
- name: Install dependencies
working-directory: frontend
run: npm install
- name: Build
working-directory: frontend
run: npm run build
- name: Deploy Files
uses: appleboy/scp-action@master
env:
HOST: ${{ secrets.aws_pull_host }}
USERNAME: ${{ secrets.aws_pull_username }}
KEY: ${{ secrets.aws_pull_private_key }}
with:
working-directory: frontend
source: build/
target: "/home/build/site/testDir/"
strip_components: 1
Run Code Online (Sandbox Code Playgroud)
每当操作到达步骤时 …
在我的 Github Actions 中,我正在云中创建一些资源,并且我希望有一份工作可以清理我的所有资源。
我看到这些操作,例如结帐,它们有一个发布操作。我们有岗位工作吗?
我目前正在这样做:
if: failure() && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/mybranch')
Run Code Online (Sandbox Code Playgroud)
但我们正在使用 git flow(令我非常懊恼)。
如何检查分支名称是否包含特定模式?
像这样的东西:
if: failure() && ( !(github.ref ~= 'feature/*' )
Run Code Online (Sandbox Code Playgroud) 我是 GitHub 模板存储库的新手。我们为课程的代码实验室创建了一个模板存储库。假设它位于 GitHub 下的myorg/labX. 学生们正在使用 GitHub Classroom,它为每个学生克隆了模板存储库myorg/labX-studentlogin。我们已经采取行动,使用 GitHub 自己的 CI 对他们的代码运行一些测试,我想在存储库的 README.md 中包含徽章,以便一目了然地查看测试结果。所以我知道

Run Code Online (Sandbox Code Playgroud)
将包含徽章,但这是模板存储库的状态,而不是学生存储库的状态。有没有一种方法可以自动执行此操作,以便当学生获得克隆时,它将包含一个自述文件,其中的 URL 引用了他们自己的存储库的状态?
我正在尝试创建一个操作,其工作流程在针对主服务器打开来自特定分支的拉取请求时运行。我目前所拥有的在所有分支针对 master 打开的所有 Pull 请求上运行工作流程。
name: Auto Approve Pull Request
on:
pull_request:
branches:
- 'master'
- 'skip-*'
jobs:
build:
name: Approve PR
runs-on: ubuntu-latest
steps:
- name: Fetch out code
uses: username/my-github-repo@master
with:
token: ******
env:
BRANCH_PREFIX: "skip-*"
PULL_REQUEST_BRANCH: "master"
Run Code Online (Sandbox Code Playgroud)
我想让工作流程仅在名为 的分支上运行skip-*。
我有一组 GitHub 操作,配置为阻止合并拉取请求,直到操作成功完成。但是,每次将新提交推送到 PR 时,操作都会再次运行,如果作者尚未准备好合并并打算进行未来更改,这可能会非常浪费。有没有办法让 GitHub Action 仍然阻止 PR 合并,但也不自动运行 Action?
我正在向我的 asp.net core 应用程序添加一个 dockerfile,它位于一个子目录中。我正在尝试创建一个 github 操作来运行 dockerfile,但该操作很难找到它。我的文件夹结构是:
api/
|--Data/
|--Service/
|--|--Dockerfile
|--Tests/
|--MyProject.sln
frontend/
Run Code Online (Sandbox Code Playgroud)
我的action.yml是:
name: Docker Image CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build ./api/Service/ --file Dockerfile --tag my-image-name:$(date +%s)
Run Code Online (Sandbox Code Playgroud)
当操作运行时,我在 docker 构建上收到以下错误。
Run docker build ./api/Service/ --file Dockerfile --tag my-image-name:$(date +%s)
docker build ./api/Service/ --file Dockerfile --tag my-image-name:$(date +%s)
shell: /bin/bash -e {0}
unable to …Run Code Online (Sandbox Code Playgroud) 我目前正在将 CI 管道从 CircleCI 迁移到 GitHub Actions,但我遇到了 Prettier 问题。我们使用 Prettier 在我们的项目中强制执行一致的代码风格,这是 CI 管道中的一个步骤。该管道在 Linux、MacOS 和 Windows 上运行。
我执行npx prettier --check "{src,test,examples}/**/*.ts"检查文件是否存在格式问题。奇怪的是,这个检查在 ubuntu-latest 和 macos-latest 上通过,但在 windows-latest 上失败。
您可以在此处查看 windows-latest 的示例输出:
Run npm run format:check
> h5p-nodejs-library@2.0.0 format:check D:\a\H5P-Nodejs-library\H5P-Nodejs-library
> npx prettier --check "{src,test,examples}/**/*.ts"
Checking formatting...
test\TemporaryFileManager.test.ts
[... nearly all our files...]
Code style issues found in the above file(s). Forgot to run Prettier?
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! h5p-nodejs-library@2.0.0 format:check: `npx prettier --check …Run Code Online (Sandbox Code Playgroud) github-actions ×10
github ×3
amazon-ecs ×1
asp.net-core ×1
docker ×1
prettier ×1
pull-request ×1
yaml ×1