Skip to content

Commit 9c325a5

Browse files
committed
try customizing branch name with github vars
1 parent ef55dfc commit 9c325a5

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

.github/workflows/dotnet.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@ jobs:
2929
- name: Checkout code
3030
uses: actions/checkout@v4
3131

32-
- name: Build NUnit example
32+
- name: Build XUnit example
3333
uses: docker/build-push-action@v4
3434
with:
3535
context: ./dotnet-xunit
3636
file: ./dotnet-xunit/Dockerfile
3737
push: false
3838
secrets: |
3939
"dotenv=${{ secrets.DOTENV }}"
40+
build-args:
41+
- GITHUB_RUN_ID=${{ GITHUB_RUN_ID }}
42+
- GITHUB_RUN_ATTEMPT=${{ GITHUB_RUN_ATTEMPT }}
4043

4144
nunit:
4245
runs-on: ubuntu-latest
@@ -52,4 +55,4 @@ jobs:
5255
file: ./dotnet-nunit/Dockerfile
5356
push: false
5457
secrets: |
55-
"dotenv=${{ secrets.DOTENV }}"
58+
"dotenv=${{ secrets.DOTENV }}"

dotnet-nunit/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@ WORKDIR /workspace
2121

2222
COPY . .
2323

24+
ARG GITHUB_RUN_ID
25+
ARG GITHUB_RUN_ATTEMPT
26+
ARG SAUCE_VISUAL_BRANCH_NAME=${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}
27+
2428
RUN --mount=type=secret,id=dotenv,target=/workspace/.env env $(cat /workspace/.env | xargs) runme run dotnet-test
2529
RUN --mount=type=secret,id=dotenv,target=/workspace/.env env $(cat /workspace/.env | xargs) runme run dotnet-test-modified

dotnet-nunit/SauceLabs.Visual.Example/SauceDemo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public async Task Setup()
3030
{
3131
Name = "My Visual Build",
3232
Project = "csharp-project",
33-
Branch = "csharp-branch"
33+
Branch = Environment.GetEnvironmentVariable("SAUCE_VISUAL_BRANCH_NAME") ?? "main"
3434
});
3535
VisualClient.CaptureDom = true;
3636
TestContext.Progress.WriteLine($"Build: {VisualClient.Build.Url}");

0 commit comments

Comments
 (0)