我试图按照他们的文档使用 github 操作将 docker 映像推送到公共 docker 存储库,但我无法使其工作:
name: CI
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/docker/login@master
with: # Set the secret as an input
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
env: # Set the secret in the env
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Test
run: mvn clean verify -U
- name: build
run: ./mvnw compile jib:dockerBuild
- name: push
run: docker push odfsoft/guess-game:latest
Run Code Online (Sandbox Code Playgroud)
我收到以下错误: …
我在 Github Actions 中使用缓存的 pip 时遇到了一些问题。我的工作流程设置是
name: tests
on: [push, pull_request]
jobs:
linux:
runs-on: ubuntu-18.04
strategy:
max-parallel: 4
matrix:
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install pytest pytest-cov bandit sphinx recommonmark
python -m pip install --upgrade …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个 GitHub Actions 工作流程,该工作流程将收集在上次提交中更改的特定路径,并为每个收集的路径(如果有)运行一个步骤。
目前,在我的工作流程中,我正在创建一个路径数组,但我不确定如何处理我的数组:
name: Test
on:
push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
# This step will create "an array" of strings, e.g. "path1 path2 path3"
- name: array
id: arr
run: |
arr=()
for i in "$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }})"
do
if [[ $i == *"path1"* ]]; then
arr+=("path1")
fi
if [[ $i == *"path2"* ]]; then
arr+=("path2")
fi
done
echo ::set-output name=arr::${arr[@]}
# How to run this step by iterating …Run Code Online (Sandbox Code Playgroud) 我有一个基本的 git 存储库,其中包含用于构建和部署的 github 操作(主要是 HTML 和 TS 文件)。
但是我必须在一些需要保密的 API 密钥中使用。
所以我想办法为他们使用 GITHUB SECRETS。
如何在我的 js(或 TS)文件中访问 GITHUB SECRETS,以便它可以正确地使用 github 操作进行构建?
我们正在从 gitlab 迁移到 github。
使用 gitlab pipelines,我检查存储库并动态生成一个包含要运行的实际作业的子管道。通过实际定义最容易解释这一点:
stages:
- bootstrap
- run
# ---------------------------------------------------------------------------
# Bootstrap
# ---------------------------------------------------------------------------
bootstrap:
stage: bootstrap
# this will write the file jobs.yml to disk
script: ./bootstrap.ps1
artifacts:
paths:
- artifacts/jobs.yml
# ---------------------------------------------------------------------------
# Run
# ---------------------------------------------------------------------------
run:
stage: run
trigger:
include:
- artifact: artifacts/jobs.yml
job: bootstrap
strategy: depend
Run Code Online (Sandbox Code Playgroud)
github actions 有类似的吗?我发现可以动态生成矩阵,但这还不够。
我需要运行相互依赖并并行/顺序运行的作业。
例子:
整个作业图是动态生成的。
在这里,我有三个阶段,所有应用程序作业并行运行,并且单个部署作业等待所有应用程序作业完成。
我还需要将应用程序作业的输出传递到部署作业,这似乎也不能真正使用矩阵:https ://github.com/github-community/community/discussions/17245
即使输出由作业的多个矩阵变体设置,也只保留一个。
那么,实际的问题是有没有一种方法可以动态生成具有多个相互依赖的作业的工作流程并执行它,或者这是不存在的东西?
我有一个工作流程,workflow_dispatch输入默认为空字符串。该工作流程使用本地 github 操作,其自定义输入及其各自的默认值:
# .github/workflow/ci.yml
on:
push:
- main
- wip/**
workflow_dispatch:
inputs:
myInput:
description: An input string
type: string
jobs:
myJob:
steps:
- name: My action step
uses: ./.github/actions/my-action
with:
myInput: ${{ github.event.inputs.myInput }}
Run Code Online (Sandbox Code Playgroud)
# .github/actions/my-action/action.yml
name: 'My action'
description: 'An action'
inputs:
myInput:
description: An input
required: false
default: 'My default input'
runs:
steps:
- name: Run
shell: bash
run: echo Input: ${{ inputs.myInput }}
Run Code Online (Sandbox Code Playgroud)
如果工作流程是由推送触发的,或者如果我使用空输入手动启动工作流程,我希望该操作my-action保留其默认输入值My default input而不是空字符串。
您知道这是否可以从工作流程中实现,而无需调整my-action操作吗?
我尝试使用 GitHub Pages(GitHub Actions 的静态 HTML)并遇到此错误。
运行 actions/configure-pages@v2.1.1
警告:获取页面站点失败
错误:创建页面站点失败
错误:AxiosError:请求失败,状态代码 403
知道如何解决吗?我的存储库中只有一个简单的index.html,其中写着
任何线索都会有帮助,谢谢。
我想以编程方式确定特定的 Python 脚本是否在测试环境中运行,例如
等等。我意识到这需要一些启发,但这对我来说已经足够了。是否总是设置某些环境变量?用户名总是相同吗?ETC。
我正在尝试在我的存储库上创建一个复合操作,如下所示:
\n.github\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 actions\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 setup-composite.yml\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 workflows\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 composite_test.yml\nRun Code Online (Sandbox Code Playgroud)\n文件的内容是最低限度的
\n# setup-composite.yml\n\nname: setup-env\n\nruns:\n using: \'composite\'\n steps:\n - uses: actions/setup-python@v4\n with:\n python-version: \'3.9\'\n\n - name: run dependencies\n shell: bash\n run: |\n pip install -r requirements.txt\n\nRun Code Online (Sandbox Code Playgroud)\n然后我尝试使用引用复合工作流程
\n# composite_test.yml\n\nname: Composite Test\non:\n pull_request:\n push:\n branches: [main]\n workflow_dispatch:\n\njobs:\n setup:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v3\n\n - name: composite\n uses: ./.github/actions/setup-composite\nRun Code Online (Sandbox Code Playgroud)\nrequirements.txt 的内容只是几个用于测试目的的包。
\n但是当这个工作流程运行时我得到Error: Can\'t find \'action.yml\', \'action.yaml\' or \'Dockerfile\' under \'/home/runner/work/_actions/{profile}/{repo}/main/.github/actions/setup-composite\'. Did you forget to run actions/checkout …
目前,我正在尝试为自动发布 java 库的 GitHub Action 做出贡献。我正在开发的分支:https://github.com/MathieuSoysal/Java-maven-library-publisher/tree/2-add-automated-tests
Action 的 yaml 代码:
name: Java maven library publisher
author: "Mathieu Soysal (@MathieuSoysal)"
description: "Build automatically Java Maven library and publish it to GitHub Packages and Maven Central."
branding:
icon: "package"
color: "gray-dark"
inputs:
nexus-username:
description: "Nexus username"
required: true
nexus-password:
description: "Nexus password"
required: true
gpg-private-key:
description: "GPG private key"
required: true
gpg-passphrase:
description: "GPG passphrase"
required: true
github-token:
description: "GitHub token"
required: true
# Java version to use
java-version: …Run Code Online (Sandbox Code Playgroud) github-actions ×10
github ×3
yaml ×2
bash ×1
cicd ×1
circleci ×1
docker ×1
github-pages ×1
gitlab-ci ×1
java ×1
javascript ×1
maven ×1
python ×1
travis-ci ×1
workflow ×1