Skip to content

Commit 8e1a0ab

Browse files
committed
Refactor deploy.yml to add support for choosing target environment
1 parent 5580a92 commit 8e1a0ab

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

.github/workflows/dotnet-deploy.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
name: .NET CI
22

3+
env:
4+
registryName: qkycf2fsjozsgmpnpreg.azurecr.io
5+
repositoryName: techexcel/dotnetcoreapp
6+
dockerFolderPath: ./src/Application/src/RazorPagesTestSample
7+
tag: ${{github.run_number}}
8+
39
on:
410
push:
511
branches: [ main ]
@@ -18,10 +24,40 @@ jobs:
1824
- uses: actions/checkout@v3
1925
- name: Setup .NET
2026
uses: actions/setup-dotnet@v3
21-
27+
with:
28+
dotnet-version: 8.0
29+
2230
- name: Restore dependencies
2331
run: dotnet restore ./src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
2432
- name: Build
2533
run: dotnet build --no-restore ./src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj
2634
- name: Test
2735
run: dotnet test --no-build --verbosity normal ./src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj
36+
37+
dockerBuildPush:
38+
39+
runs-on: ubuntu-latest
40+
needs: build
41+
42+
steps:
43+
- uses: actions/checkout@v3
44+
45+
- name: Docker Login
46+
# You may pin to the exact commit or the version.
47+
# uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
48+
uses: docker/[email protected]
49+
with:
50+
# Server address of Docker registry. If not set then will default to Docker Hub
51+
registry: ${{ secrets.ACR_LOGIN_SERVER }}
52+
# Username used to log against the Docker registry
53+
username: ${{ secrets.ACR_USERNAME }}
54+
# Password or personal access token used to log against the Docker registry
55+
password: ${{ secrets.qkycf2fsjozsgmpnpreg }}
56+
# Log out from the Docker registry at the end of a job
57+
logout: true
58+
59+
- name: Docker Build
60+
run: docker build -t $registryName/$repositoryName:$tag --build-arg build_version=$tag $dockerFolderPath
61+
62+
- name: Docker Push
63+
run: docker push $registryName/$repositoryName:$tag

0 commit comments

Comments
 (0)