所以我尝试在 Github Actions 环境中运行这些命令:
sudo update-alternatives --config x86_64-w64-mingw32-gcc
sudo update-alternatives --config x86_64-w64-mingw32-g++
将线程模型更改为POSIX,但会弹出以下提示:
There are 2 choices for the alternative x86_64-w64-mingw32-gcc (providing /usr/bin/x86_64-w64-mingw32-gcc).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/x86_64-w64-mingw32-gcc-win32 60 auto mode
1 /usr/bin/x86_64-w64-mingw32-gcc-posix 30 manual mode
2 /usr/bin/x86_64-w64-mingw32-gcc-win32 60 manual mode
Run Code Online (Sandbox Code Playgroud)
在无法访问 shell 的情况下如何回答这个问题?我尝试给出 1 作为命令(不起作用),这些:
echo "1" > sudo update-alternatives --config x86_64-w64-mingw32-gcc
echo "1" > sudo update-alternatives --config x86_64-w64-mingw32-g++
但我使用sudo update-alternatives --config x86_64-w64-mingw32-gcc和sudo update-alternatives --config x86_64-w64-mingw32-g++检查后,提示仍然显示选择为0。(如果你手动更改选项,它应该记住你的选择)
我该怎么办?任何帮助表示赞赏。
我正在关注这个。
https://github.community/t/github-actions-manual-trigger-approvals/16233/83
- name: Clone Repository (Latest)
uses: actions/checkout@v2
if: github.event.inputs.git-ref == ''
- name: Clone Repository (Custom Ref)
uses: actions/checkout@v2
if: github.event.inputs.git-ref != ''
with:
ref: ${{ github.event.inputs.git-ref }}
Run Code Online (Sandbox Code Playgroud)
这工作正常,但多步骤会使工作流程更大。我正在尝试更紧凑的东西。
就像确定 env 中的提交 SHA 一样。
env:
COMMIT_HASH: ${{ github.event.inputs.git-ref != '' && github.event.inputs.git-ref || github.sha }}
Run Code Online (Sandbox Code Playgroud)
这工作正常,但对我来说看起来像是一个丑陋的黑客。有什么建议。我试图避免额外的步骤,仅此而已。
例如,在我的存储库中,我有 3 个 github 操作工作流程:linting(L)、unittests(U) 以及 build(B) 工作流程,我只想在 L 和 U 完成时触发。L 和 U 都会在推送事件时自动触发。如果我在 B 工作流程中执行此操作:
workflow_run:
workflows: ["Lint", "UnitTests"]
types:
- completed
Run Code Online (Sandbox Code Playgroud)
我的构建工作流程被触发两次,第一次是 L 完成时,第二次是 U 完成时。是否可以在L和U都完成后才触发B一次?
我正在使用 NUnit.Framework 来测试我的 .NET Framework 项目。我想通过 GitHub Actions 运行我的测试。yml 文件:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.0.x'
- name: Setup MSBuild Path
uses: microsoft/setup-msbuild@v1
- name: Build
run: msbuild.exe .\CalcStatistics\CalcStats\CalcStats.sln
- name: Setup VSTest and add to PATH
uses: darenm/Setup-VSTest@v1
- name: Run VSTest
id: run_vstest
run: vstest.console.exe .\CalcStatistics\CalcStats\CalcStatsTests\bin\Debug\CalcStatsTests.dll /Platform:x64
Run Code Online (Sandbox Code Playgroud)
我得到的回应是:没有可用的测试。我尝试使用以下命令通过 MsBuild 运行测试:
run:& "$(vswhere -property installationPath)\Common7\IDE\MSTest.exe" /testcontainer:.\CalcStatistics\CalcStats\CalcStatsTests\bin\Debug\CalcStatsTests.dll
Run Code Online (Sandbox Code Playgroud)
env我对 Github Actions 中的作业有以下定义:
jobs:
build-test-deploy:
runs-on: ubuntu-latest
env:
FOO : foobar-${{ github.sha }}
BAR : BAZ
Run Code Online (Sandbox Code Playgroud)
但是,github.sha当重新运行相同的工作流程且中间没有任何提交时,结果保持不变。我需要FOO每次运行都是唯一的(即使它在技术上是重新运行),与提交无关。
我正在考虑的两个选择:
我不知道如何在指令的上下文中获取这些值env:。有一些操作可以在其中使用steps,但是如何才能直接从env指令中获取这种唯一值呢?
我尝试使用 firebase 创建实时预览。我写了yml文件,但它总是失败。
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
name: Deploy to Firebase Hosting on PR
'on': pull_request
jobs:
build_and_preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
- run: npm ci
- run: npm run build
- name: Deploy
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_SAIKAI_PRODUCTION }}'
projectId: saikai-production
Run Code Online (Sandbox Code Playgroud)
和我的错误:
Run FirebaseExtended/action-hosting-deploy@v0
/home/runner/work/_actions/FirebaseExtended/action-hosting-deploy/v0/bin/action.min.js:1
function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("os")),r=require("fs"),i=e(r),n=e(require("path")),s=e(require("stream")),o=e(require("http")),a=e(require("url")),p=e(require("https")),u=e(require("zlib"));require("net");var c=e(require("tls")),d=e(require("events")),l=e(require("assert")),g=e(require("util")),m=e(require("crypto")),h=e(require("child_process")),y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof …Run Code Online (Sandbox Code Playgroud) github web-deployment firebase firebase-hosting github-actions
我有一个工作流程,它创建一个新分支,其名称保存为环境变量。原因是我需要工作流程在新的干净分支上运行。
1 工作之后我想去看看分行。问题是我似乎无法在“ref”上使用环境变量来检查它。
有没有办法做到这一点 ?或者 github 还不支持这个吗?
示例代码:
- name: Checkout to branch
uses: actions/checkout@v2
with:
repository: org/repo
token: ${{secrets.GIT_TOKEN}}
ref: $NEW_BRANCH_NAME
Run Code Online (Sandbox Code Playgroud)
[编辑] 答案:
对于遇到同样问题的任何人,这就是我最终的做法:首先我创建了一个仅创建并推送一个新分支的作业:
Create-new-Branch:
runs-on: [ self-hosted ]
outputs:
branch_name: ${{ steps.create-branch.outputs.BRANCH_NAME}}
steps:
- name: Checkout master
uses: actions/checkout@v2
with:
repository: org/repo
token: ${{secrets.GIT_TOKEN}}
ref: master
- name: create and push branch
id: create-branch
run: |
export TEST="new-branch-name-`date '+%F'`"
git checkout -b $TEST origin/master
git push -u origin $TEST
echo "::set-output name=BRANCH_NAME::$TEST"
Run Code Online (Sandbox Code Playgroud)
然后在下一个作业中,当我想使用它时,我使用上面作业的作业输出作为存储库名称
Job-Name:
needs: Create-new-Branch
runs-on: [self-hosted] …Run Code Online (Sandbox Code Playgroud) 我创建了一个 github 操作来在推送时部署代码。
安装软件包时会导致此错误。
Run npm i --no-optional && cd client && npm i --no-optional && cd ..
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS: darwin
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: linux
npm ERR! notsup Actual …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的 GitHub 操作的 IP 地址列入白名单,因为目前工作流程因我的 Azure Web 应用程序的防火墙阻止来自非白名单 IP 地址的请求而失败。看来Github提供的这个API中有一个CIDR格式的IP地址列表: https: //api.github.com/meta
但是,我是 Azure 新手,不知道如何通过 Azure UI 中的 API 将如此大量的 IP 地址列入白名单。当我转到 Azure 应用程序的“网络”页面,转到“访问限制”并单击“配置访问限制”时,有一个非常好的 GUI 可以将单个 IP 地址列入白名单,但似乎没有办法要访问 API,我想知道是否有人知道我应该如何尝试从上面链接的 GitHub API 页面访问“操作”:[IP1、IP2 等],并将该 IP 数组纳入我的访问限制配置,理想情况下这应该是动态的,因为显然 Github 有时会更新此页面......
任何建议表示赞赏!提前致谢。
我正在使用 GitHub Actions CI/CD 工作流程来自动执行构建、测试和部署步骤。为了成功构建项目,我需要包含一个秘密变量(在设置中定义)以写入 application.properties 文件。但是,在构建时在文件中找不到该变量。这是工作流程 yml 文件
name: Build and deploy JAR app to Azure Web App - harry-kart-web-api
on:
push:
branches:
- master
workflow_dispatch:
jobs:
compile:
runs-on: windows-latest
name: Running Java ${{ matrix.java }} compile
steps:
- uses: actions/checkout@v2
- name: Set up Java version
uses: actions/setup-java@v1
with:
java-version: '11'
- name: Compile code
run: mvn compile
test:
runs-on: windows-latest
name: Running tests
needs: compile
steps:
- uses: actions/checkout@v2
- name: Set up Java version
uses: actions/setup-java@v1 …Run Code Online (Sandbox Code Playgroud)