我开始使用 GitHub Actions,我能够为 Elixir 设置 CI 管道,操作构建和测试没有任何问题。我还想使用 heroku 操作部署应用程序,所以我继续添加了 GitHub 中可用的应用程序,但在这样做之后,我收到以下错误:
无效的工作流文件每一步都必须定义一个使用或运行密钥
这是我的工作流程在添加 heroku 操作之前的样子:
name: Elixir CI
on: push
jobs:
build:
runs-on: ubuntu-latest
container:
image: elixir:1.9.1-slim
steps:
- uses: actions/checkout@v1
- name: Install Dependencies
run: |
mix local.rebar --force
mix local.hex --force
mix deps.get
test:
runs-on: ubuntu-latest
services:
db:
image: postgres:11
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v1.0.0
- uses: actions/setup-elixir@v1.0.0
with:
otp-version: 22.x
elixir-version: 1.9.x
- run: mix deps.get …Run Code Online (Sandbox Code Playgroud) I want to build a docker image using a GitHub action, migrating from TeamCity.
In the build script, I want to tag the image with a combination of branch and commit, e.g. master.ad959de. Testing that locally, I get that information like this:
git_branch=`git symbolic-ref --short HEAD`
git_hash=`git rev-parse --short HEAD`
docker_version=${git_branch}.${git_hash}
Run Code Online (Sandbox Code Playgroud)
This is the relevant part of the GitHub action:
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Create docker image
run: ./docker-build.sh …Run Code Online (Sandbox Code Playgroud) 我正在开发 R 包并使用 GitHub Action (GHA) 作为持续集成 (CI) 提供程序。我使用actions/cache. 现在我想清除所有缓存。我怎样才能做到这一点?
on: push
name: R-CMD-check
jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
strategy:
fail-fast: false
matrix:
config:
# - {os: windows-latest, r: 'devel'}
- {os: macOS-latest, r: 'release'}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@master
- name: Query dependencies
run: |
repos <- c("https://r-hyperspec.github.io/hySpc.pkgs/", getOption("repos"))
saveRDS("remotes::dev_package_deps(dependencies = TRUE)", ".github/depends.Rds", …Run Code Online (Sandbox Code Playgroud) 有什么区别
steps:
- name: npm install, build, and test
run: |
npm ci
npm run build --if-present
npm test
Run Code Online (Sandbox Code Playgroud)
和
steps:
- name: npm install, build, and test
- run: npm ci
- run: npm run build --if-present
- run: npm test
Run Code Online (Sandbox Code Playgroud)
在 github 操作中?我试图阅读有关步骤的文档,但它没有提到类似的内容
使用 Travis CI,我们可以通过向提交添加后缀来跳过特定提交的构建。这在Travis CI 中有描述。当我只编辑README.md与代码无关的内容并且不需要触发飞行前构建时,我发现此功能很实用。
[skip ci]
Run Code Online (Sandbox Code Playgroud)
如何on: push使用 GitHub 操作跳过作业触发事件?
name: Maven Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check-out project
uses: actions/checkout@v1
- name: Set up JDK 11.0.3
uses: actions/setup-java@v1
with:
java-version: 11.0.3
- name: Build with Maven
run: mvn -B package --file pom.xml
Run Code Online (Sandbox Code Playgroud)
答案摘要:
非常感谢所有提供各种方法来实现它的回答者。我敢打赌,每个人在问题的起源和 CI 方法方面都需要一些不同的东西。以下是为快速导航列出的答案:
readme.md文件中的CI :https : //stackoverflow.com/a/61876395/3764965[skip ci]作为一个新的 GitHub 功能:
[skip ci] …我有一个 Yarn monorepo(工作区),有 2 个包:后端(Node.js/TypeScript)和前端(React/Typescript)。
\n/package.json(已修剪)
{\n "workspaces": [\n "backend",\n "frontend"\n ],\n}\nRun Code Online (Sandbox Code Playgroud)\n我正在尝试添加与 GitHub Actions 的持续集成,并尝试使用它actions/cache@v2来缓存 Yarn 缓存目录和所有项目'node_modules目录
.github/workflows/CI.yml(已修剪)
steps:\n - uses: actions/checkout@v2\n\n - name: Get yarn cache directory path\n id: yarn-cache-dir-path\n run: |\n echo "::set-output name=dir::$(yarn cache dir)"\n echo "::set-output name=version::$(yarn -v)"\n\n - name: Use Node.js ${{ matrix.node-version }}\n uses: actions/setup-node@v2\n with:\n node-version: ${{ matrix.node-version }}\n\n - uses: actions/cache@v2\n with:\n path: |\n ${{ steps.yarn-cache-dir-path.outputs.dir }}\n '**/node_modules'\n '**/.eslintcache'\n key: …Run Code Online (Sandbox Code Playgroud) 假设 CI 工作流程正在运行,如何查看完整日志?
2022-07-14T16:29:41.4911629Z Requested labels: ubuntu-latest
2022-07-14T16:29:41.4911713Z Job defined at: username/repo/.github/workflows/main.yml@refs/heads/main
2022-07-14T16:29:41.4911751Z Waiting for a runner to pick up this job...
2022-07-14T16:29:42.2335026Z Job is waiting for a hosted runner to come online.
2022-07-14T16:29:48.5809023Z Job is about to start running on the hosted runner: Hosted Agent (hosted)
Run Code Online (Sandbox Code Playgroud)
但我知道还有更多。
我正在开发 Github 操作工作流。此工作流在 Linux、Mac 和 Windows 上运行。
作为工作流程的一部分,我必须检查 2 个环境变量是否相等。如果他们不这样做 - 失败的工作。
如上所述这里,Github上操作支持if:条件:
steps:
- run: # How can I make a cross-platform failure here?
if: ${{ envA }} != ${{ envB }}
Run Code Online (Sandbox Code Playgroud)
如果上述条件为真,我怎样才能使工作失败?一开始,我想到了一个脚本,但必须有一个更优雅的方式来失败一个工作。
我有一个用于发布存储库夜间快照的 GitHub 工作流程。它使用create-release 操作。这是工作流文件现在的样子:
name: Release Nightly Snapshot
on:
schedule:
- cron: "0 0 * * *"
jobs:
build:
name: Release Nightly Snapshot
runs-on: ubuntu-latest
steps:
- name: Checkout master Branch
uses: actions/checkout@v2
with:
ref: 'master'
- name: Create Release
id: nightly-snapshot
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: 'nightly snapshot'
release_name: 'nightly snapshot'
draft: false
prerelease: false
Run Code Online (Sandbox Code Playgroud)
我想要tag_name并release_name使用当前日期和时间,而不是硬编码值。但是,我找不到任何关于它的文档。我该怎么做?
是否有可能仅在推送新版本(带有新标签)时触发 github 操作?我不想在每次推送到 master 时运行它们,但我也想避免创建发布分支。