我正在尝试为我的 github 存储库设置 CI。每次推送沙箱分支后,我想构建一个 docker 镜像我的项目并推送到 AWS ECR。
这是我的 .github/workflows/aws.yml 文件 -
name: be-harvester CI
on:
pull_request:
branches:
- sandbox
push:
branches:
- sandbox
env:
AWS_REPOSITORY_URL: ${{ secrets.AWS_REPOSITORY_URL }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
jobs:
build-and-push:
name: Build and push image to AWS ECR
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Check REPO url
run: echo $AWS_REPOSITORY_URL
- name: Setup ECR
run: $( aws ecr get-login --no-include-email --region ap-south-1)
- name: Build and tag …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置一些基本的 GitHub 操作来对 PR 写评论。
操作发布在 github 上,如下所示:
action.yml 文件:
name: !!name!!
description: !!description!!
author: !!me!!
inputs:
token:
description: "Github token"
required: true
runs:
using: "node12"
main: "index.js"
Run Code Online (Sandbox Code Playgroud)
index.js 文件:
const core = require("@actions/core");
const { execSync } = require("child_process");
const { GitHub, context } = require("@actions/github");
const main = async () => {
const repoName = context.repo.repo;
const repoOwner = context.repo.owner;
const token = core.getInput("token");
const testCommand = "yarn test --watchAll=false";
const prNumber = context.payload.number;
const githubClient = new …Run Code Online (Sandbox Code Playgroud) 我正在尝试实施 github 操作以将 django 项目部署到我的 Google Compute Engine,但无法实现。
我正在关注本教程:https : //testdriven.io/blog/deploying-django-to-digitalocean-with-docker-and-github-actions/
错误日志说:
/home/runner/work/_temp/f***572db0-***32d-4053-8b60-f5d54780dd7c.sh:第4行:意外标记附近的语法错误`)'
name: Continuous Integration and Delivery
on: [push]
env:
WEB_IMAGE: docker.pkg.github.com/$GITHUB_REPOSITORY/web
CHANNELS_IMAGE: docker.pkg.github.com/$GITHUB_REPOSITORY/channels
jobs:
build:
name: Build Docker Images
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v1
- name: Add environment variables to .env
run: |
echo DEBUG=0 >> .env
echo SQL_ENGINE=django.db.backends.postgresql_pyscopg2 >> .env
echo DATABASE=postgres >> .env
echo SECRET_KEY=${{ secrets.SECRET_KEY }} >> .env
echo SQL_DATABASE=${{ secrets.SQL_DATABASE }} >> .env
echo SQL_USER=${{ secrets.SQL_USER }} >> …Run Code Online (Sandbox Code Playgroud) 我曾多次尝试将工件部署到https://maven.pkg.github.com,.github/workflows但它们都导致 401 Unauthorized 错误。
- name: Setup java for mvn deploy
uses: actions/setup-java@v1
with:
java-version: 8
- name: Deploy kaldi-linux.zip
working-directory: kaldi
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
cp ../.github/kaldi/* .
perl -pi -e 's/^(\s{4}<version>).*(<\/version>)/${1}$ENV{"KALDI_VERSION"}${2}/g' pom.xml
mvn deploy
Run Code Online (Sandbox Code Playgroud)
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy)
on project kaldi: Failed to deploy artifacts: Could not transfer artifact org.kaldi:kaldi:pom:da93074
from/to temp (https://maven.pkg.github.com/nalbion/vosk-api): Transfer failed for
https://maven.pkg.github.com/nalbion/vosk-api/org/kaldi/kaldi/da93074/kaldi-da93074.pom 401 Unauthorized -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
在这里记录:https : //github.com/nalbion/vosk-api/runs/683615393?check_suite_focus=true
我的理解是actions/setup-java …
我的应用程序在 docker 中运行并设置 Github Actions 来运行我的测试。为了运行 Behat 测试,我有一个单独的测试数据库,因此还有一个单独的 .env 可以使用。
在 .env.test
DATABASE_URL=mysql://root:emc@mysql:3306/emc_test?serverVersion=5.7
Run Code Online (Sandbox Code Playgroud)
在 docker-compose.test.yml
version: "3.7"
services:
mysql:
build:
context: docker/mysql
dockerfile: Dockerfile
volumes:
- mysql-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: emc
MYSQL_USER: emc
MYSQL_PASSWORD: emc
MYSQL_DATABASE: emc
TZ: Europe/Brussels
ports:
- "3306:3306"
networks:
- backend
cli:
image: christianvermeulen/itexperts:latest
volumes:
- .:/application:cached
- app-cache:/application/var/cache
- composer:/composer
networks:
- backend
volumes:
composer:
app-cache:
mysql-data:
networks:
backend:
Run Code Online (Sandbox Code Playgroud)
一旦我点击数据库,我就会收到一个连接被拒绝的消息。我在 Symfony 中设置了这个测试命令:
DATABASE_URL=mysql://root:emc@mysql:3306/emc_test?serverVersion=5.7
Run Code Online (Sandbox Code Playgroud)
最后我还想看看一些信息,所以我在 Github Actions 中运行以下命令:
- name: Prepare Testing
run: |
cp docker-compose.test.yml docker-compose.yml …Run Code Online (Sandbox Code Playgroud) 我编写了一个简单的 Github 操作来检查在提出 PR 时是否满足了我的 linting 规则。但是每当我运行它时,我都会收到错误消息“没有在jobs“中定义作业”。我怎样才能解决这个问题?
name: Check rules
on:
pull_request:
branches:
- develop
- master
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
check-latest: true
- run: npm install
- run: npm check-rules
Run Code Online (Sandbox Code Playgroud) 对于公共存储库,在 github 操作中,假设我的操作在 azure 中的计算上运行。如果 CI 管道必须在 azure 中运行,我对如何保护 azure auth 细节感到困惑。
让我们说要使用这个动作,我必须使用一个秘密,我将一个环境变量的值设置为秘密 - 我没有失去拥有秘密的意义吗?恶意用户可以发送打印环境变量值的 PR:
user_password: {{secret.USER_PASSWORD}}
Run Code Online (Sandbox Code Playgroud)
用户代码:
print(os.environment['user_password'])
Run Code Online (Sandbox Code Playgroud)
恶意用户不必猜测,因为工作流程是公开的,并且他知道哪个 env var 拥有秘密。
我哪里错了?
我创建了一个 GitHub 操作,以便创建一个新版本并为我们的 JS 存储库发布它。它看起来类似于这个
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.18.3
registry-url: https://npm.pkg.github.com/
scope: '<redacted>'
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
- name: Bump Version & Push
run: |
git config --local user.email "<redacted>"
git config --local user.name "<redacted>"
npm version patch
git push https://${{ secrets.KEY }}@github.com/<redacted> HEAD:master --follow-tags
Run Code Online (Sandbox Code Playgroud)
我使用的 KEY 是我从我的帐户创建的个人访问令牌。我已经设置了 repo,以便我可以推送访问 master 分支。当我使用访问令牌从我的机器尝试推送命令时,它可以正常工作。但是每次我在 GitHub …
我有一个 bookdown 文档,它在我的本地机器上呈现得很好,但是当我使用 GitHub Actions 作为自动化进程运行时,来自各个代码块的输出显示全部混乱:

这是本书的 GitHub 存储库:https : //github.com/ries9112/cryptocurrencyresearch-org
这里是通过 GitHub Actions 自动运行的地方:https : //github.com/ries9112/cryptocurrencyresearch-org/actions
为了帮助解决问题,我创建了一个单独的存储库作为一个更加准系统的示例,并且我遇到了完全相同的问题。这是更简单示例的存储库:https : //github.com/ries9112/bookdown-test
我部署了那个更简单的测试的结果,你可以在这里找到它们:https : //brave-leakey-37b898.netlify.app/intro.html#here-adding-new-test

文档格式在本地完全没问题,所以看起来我可能需要安装其他东西,但我目前正在安装 pandoc 和 tinytex,我不知道还有什么可能会丢失。这是定义 GitHub 操作的 YAML 文件:
jobs:
build:
runs-on: macOS-10.15
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@v1
- name: Install pandoc and pandoc citeproc
run: |
brew install pandoc
brew install pandoc-citeproc
- name: Install Packages
run: |-
Rscript -e "install.packages(c('pins','bookdown','tidyverse','DT'))"
- name: Refresh book
run: |-
Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::gitbook')" …Run Code Online (Sandbox Code Playgroud) 我想在工作流程中动态指定一个策略矩阵。所以,而不是:
strategy:
matrix:
foo: [bar, baz]
Run Code Online (Sandbox Code Playgroud)
我想首先调用一些脚本,该脚本将计算并返回一个数组,例如[bar, baz]给我,然后我想将其用作策略矩阵。
这可能吗?
github-actions ×10
github ×3
aws-ecr ×1
bookdown ×1
docker ×1
mysql ×1
package.json ×1
r ×1
r-markdown ×1
yaml ×1