标签: github-actions

如何连接到 GitHub Action 的作业服务?

GitHub Actions 允许您在每个作业的基础上运行后台服务。按照示例进行操作后,我无法弄清楚如何连接到正在运行的 PostgreSQL 容器。

我在这个pull request 中尝试了几种不同的方法,但都没有奏效。

name: dinosql test suite
on: [push]
jobs:

  build:
    name: Build
    runs-on: ubuntu-latest

    services:
      postgres:
        image: postgres
        env:
          POSTGRES_PASSWORD: postgres
        ports:
          - 5432/tcp

    steps:
    - uses: actions/checkout@master

    - name: Test dinosql/ondeck
      run: go test -v ./...
      working-directory: internal/dinosql/testdata/ondeck
      env:
        PG_USER: postgres
        PG_DATABASE: postgres
        PG_PASSWORD: postgres
        PG_PORT: ${{ job.services.postgres.ports['5432'] }}
Run Code Online (Sandbox Code Playgroud)

此设置导致以下错误

Run go test -v ./...
=== RUN   TestQueries
=== PAUSE TestQueries
=== RUN   TestPrepared
=== PAUSE TestPrepared
=== CONT …
Run Code Online (Sandbox Code Playgroud)

postgresql github github-actions

6
推荐指数
1
解决办法
2497
查看次数

如何使用 GitHub 操作拒绝来自存储库成员的推送?

我的任务如下:在收到新的提交(通过单次推送)时,有必要执行 github 操作,该操作将通过 ssh(使用git pullnpm test)将任务发送到测试服务器上进行测试。然后,如果测试失败,则应取消此推送(其中的所有提交)。

第一部分,似乎没有问题,但是我想不出如何实现第二部分,即取消推送。感谢您对问题的关注!

git github github-actions

6
推荐指数
1
解决办法
2817
查看次数

Github操作:在特定操作系统上运行步骤

我正在所有操作系统上运行工作流。

但是,有一个特定步骤只能在Ubuntu上运行:

runs-on: ${{ matrix.os }}
strategy:
    matrix:
        os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
    - name: Setup Ubuntu
      run : export DISPLAY="127.0.0.1:10.0"
      if: # --> What should be here? <--
Run Code Online (Sandbox Code Playgroud)

我找不到任何示例,也找不到有关如何在特定OS上运行步骤的解释。

有人可以帮忙吗?

github-actions

6
推荐指数
2
解决办法
171
查看次数

GitHub Actions:如何在 Windows 或 macOS 上运行“服务”?

我想测试一个应该使用 GitHub Actions 连接到 PostgreSQL 和 MySQL 服务器的 CLI,如果可能的话,在所有平台上:Linux、Windows 和 macOS。

我找到了有关如何运行 Postgresservice以及如何运行 MySQL 的说明service并将它们组合成一个工作流

name: Test
on: [push]

jobs:

    init_flow:
        name: 'Run MySQL and Postgres on ${{ matrix.os }}'
        runs-on: ${{ matrix.os }}
        strategy:
            fail-fast: false
            matrix:
                os: [ubuntu-latest, windows-latest, macOS-latest]

        # via https://github.com/actions/example-services/blob/master/.github/workflows/postgres-service.yml
        services:
            postgres:
                image: postgres:10.8
                env:
                    POSTGRES_USER: postgres
                    POSTGRES_PASSWORD: postgres
                    POSTGRES_DB: postgres
                ports:
                # will assign a random free host port
                - 5432/tcp
                # needed because the postgres …
Run Code Online (Sandbox Code Playgroud)

mysql postgresql github-actions github-actions-services

6
推荐指数
2
解决办法
2378
查看次数

如何在 github-actions 中使用可变泊坞窗图像?

我正在尝试编写一个自定义 github-action,它在 docker 容器中运行一些命令,但允许用户选择他们在哪个 docker 容器中运行(即,我可以在不同版本的运行时环境中运行相同的构建指令)

我的直觉是将我的.github/actions/main/action.yml文件作为

name: 'Docker container command execution'
inputs:
  dockerfile:
    default: Dockerfile_r_latest
runs:
  using: 'docker' 
  image: '${{ inputs.dockerfile }}'
  args:
   - /scripts/commands.sh
Run Code Online (Sandbox Code Playgroud)

但是,此错误与: ##[error](Line: 7, Col: 10): Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.dockerfile

任何帮助,将不胜感激 !

文件参考

我的.github/workflow/build_and_test.yml文件是:

name: Test Package

on: 
  [push, pull_request]

jobs:

  R_latest:

    name: Test on latest
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
        name: Checkout project

      - uses: ./.github/actions/main
        name: Build and test
        with:
          dockerfile: Dockerfile_r_latest …
Run Code Online (Sandbox Code Playgroud)

docker github-actions

6
推荐指数
1
解决办法
3210
查看次数

增加节点 docker 镜像中的观察者

需要在 docker 镜像中增加观察者,因为它在 expo 发布时失败并出现错误

[11:39:08] Error: ENOSPC: System limit for number of file watchers reached, watch '/__w/mevris-client-app-products/mevris-client-app-products/node_modules/update-notifier/node_modules/camelcase'
[11:39:08]     at FSWatcher.start (internal/fs/watchers.js:165:26)
[11:39:08]     at Object.watch (fs.js:1258:11)
[11:39:08]     at NodeWatcher.watchdir (/__w/mevris-client-app-products/mevris-client-app-products/node_modules/metro/node_modules/sane/src/node_watcher.js:159:22)
[11:39:08]     at Walker.<anonymous> (/__w/mevris-client-app-products/mevris-client-app-products/node_modules/metro/node_modules/sane/src/common.js:109:31)
[11:39:08]     at Walker.emit (events.js:198:13)
[11:39:08]     at /__w/mevris-client-app-products/mevris-client-app-products/node_modules/walker/lib/walker.js:69:16
[11:39:08]     at go$readdir$cb (/__w/mevris-client-app-products/mevris-client-app-products/node_modules/@react-native-community/cli/node_modules/graceful-fs/graceful-fs.js:187:14)
[11:39:08]     at FSReqWrap.args [as oncomplete] (fs.js:140:20)
Run Code Online (Sandbox Code Playgroud)

在 Dockerfile 中添加了以下几行

RUN echo "fs.inotify.max_user_instances=524288" >> /etc/sysctl.conf && sysctl -p
Run Code Online (Sandbox Code Playgroud)

构建时导致此错误 sysctl: setting key "fs.inotify.max_user_watches": Read-only file system

我需要在 Github Actions 中使用那个 docker 镜像

文件

FROM node:10

RUN …
Run Code Online (Sandbox Code Playgroud)

node.js docker file-watcher dockerfile github-actions

6
推荐指数
2
解决办法
6639
查看次数

如何使用 GitHub 操作访问 GitHub 问题评论正文?

这是为 GitHub 问题评论设置操作触发器的方式.github/workflows/main.yml

on:
  issue_comment:
    types: [created, edited]
Run Code Online (Sandbox Code Playgroud)

假设我也可以阅读里面的问题评论main.yml并将其作为输入参数传递给我的操作。

我如何实际阅读问题评论body

github-actions

6
推荐指数
2
解决办法
1065
查看次数

Github 操作错误;无法看到 git diff 到 Master

我正在尝试找到一种方法来仅检查当前分支上已更改的 Markdown 文件。我编写了一个 bash 脚本,它在本地运行良好,但在 Github Actions 中中断。

预期结果:仅对拉取请求的 GitHub Actions 分支上已更改的 Markdown 文件进行 lint 处理。

#!/bin/bash
files=`git diff --name-only master`
for x in $files;
do
    if [ ${x: -3} == ".md" ]
    then
        node_modules/.bin/markdownlint $x
    fi
done
Run Code Online (Sandbox Code Playgroud)

我在 package.json 中调用脚本

"scripts": {
    "test": "bash mdlint.sh"
  }
Run Code Online (Sandbox Code Playgroud)

然后,我在 GitHub Actions 工作流程中调用 bash 脚本:

name: CI

on: 
  pull_request:
    branches:
    - master

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
      with:
        fetch-depth: 1
    - uses: actions/setup-node@master
    - name: lint all markdownfiles
      run: …
Run Code Online (Sandbox Code Playgroud)

bash linter github-actions

6
推荐指数
1
解决办法
3680
查看次数

Github 操作 echo 命令未创建文件

我正在将一个可用的 CircleCI 工作流转移到 Github Actions。

我在跑:

runs-on: ubuntu-latest

container: 
  image: google/cloud-sdk:latest
Run Code Online (Sandbox Code Playgroud)

我运行以下命令:

echo ${{ secrets.GCLOUD_API_KEYFILE }} > ./gcloud-api-key.json
Run Code Online (Sandbox Code Playgroud)

在运行此命令之前,尚未创建gcloud-api-key.json。此命令在 CircleCI 中有效,但在 Github Actions 中出现错误:

/__w/_temp/asd987as89d7cf.sh: 2: /__w/_temp/asd987as89d7cf.sh: type:: not found

有谁知道这个错误是什么意思?

github-actions

6
推荐指数
1
解决办法
508
查看次数

GitHub Actions:fastlane 匹配无法解密存储库

我目前正在尝试使用 GitHub Actions 为我们的 React Native 应用程序设置一个基本的测试运行器。我们在证书和整个部署中使用 fastlane,因此我们也期待在 GitHub Actions 上使用它。\n不过,我似乎无法获得 fastlane 匹配来解密我们的密钥存储库。这是我们目前的 GitHub 工作流程:

\n\n
name: Test app build\n\non:\n  pull_request:\n    branches:\n      - develop\n    types:\n      - opened\n      - reopened\n\njobs:\n  build:\n    name: Install dependencies, lint and build\n    runs-on: macOS-latest\n    strategy:\n      matrix:\n        destination: [\'platform=iOS Simulator,OS=13.1,name=iPhone 8\']\n        xcode: [\'/Applications/Xcode_11.1.app/Contents/Developer\']\n    steps:\n      - uses: actions/checkout@v1\n      - name: Install NPM packages\n        run: npm install\n      - name: Install pods\n        run: cd ios && pod install && cd ..\n      - name: Run ESLint\n        run: ./node_modules/.bin/eslint --ignore-path .gitignore .\n …
Run Code Online (Sandbox Code Playgroud)

github fastlane github-actions

6
推荐指数
1
解决办法
3963
查看次数