Skip to content

Commit 57d89bd

Browse files
feat: setting up deployment of application
#2
1 parent 2a8710b commit 57d89bd

File tree

6 files changed

+56
-30
lines changed

6 files changed

+56
-30
lines changed

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Install .NET Core
3535
uses: actions/setup-dotnet@v3
3636
with:
37-
dotnet-version: 8.x.x
37+
dotnet-version: 9.x.x
3838

3939
# Execute the build
4040
- name: Execute Release Build
@@ -54,7 +54,7 @@ jobs:
5454
- name: Install .NET Core
5555
uses: actions/setup-dotnet@v3
5656
with:
57-
dotnet-version: 8.x.x
57+
dotnet-version: 9.x.x
5858

5959
# Execute the tests
6060
- name: Execute Tests
@@ -114,7 +114,7 @@ jobs:
114114
- name: Install .NET Core
115115
uses: actions/setup-dotnet@v3
116116
with:
117-
dotnet-version: 8.x.x
117+
dotnet-version: 9.x.x
118118

119119
# Execute the build
120120
- name: Execute Build

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
1+
FROM mcr.microsoft.com/dotnet/runtime:9.0 AS base
22
USER $APP_UID
33
WORKDIR /app
4+
EXPOSE 8080
5+
EXPOSE 8081
46

5-
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
7+
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
68
ARG BUILD_CONFIGURATION=Release
79
WORKDIR /src
8-
RUN ls -a
10+
911
COPY ["src/Nullinside.Cicd.GitHub/Nullinside.Cicd.GitHub.csproj", "Nullinside.Cicd.GitHub/"]
1012
RUN dotnet restore "Nullinside.Cicd.GitHub/Nullinside.Cicd.GitHub.csproj"
1113
COPY . .

docker-compose.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: nullinside-cicd-github
2+
services:
3+
nullinside-cicd-github:
4+
build:
5+
context: .
6+
tags:
7+
- "nullinside-cicd-github:latest"
8+
logging:
9+
driver: loki
10+
options:
11+
loki-url: 'http://192.168.1.4:3100/loki/api/v1/push'
12+
container_name: nullinside-cicd-github
13+
environment:
14+
- GITHUB_PAT
15+
ports:
16+
- 8081:8080
17+
- 8082:8081
18+
restart: unless-stopped
19+
image: nullinside-cicd-github:latest

go.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
docker build -t nullinside-cicd-github:latest .
2-
docker container stop nullinside-cicd-github
3-
docker container prune -f
4-
docker run -d --name=nullinside-cicd-github -e GITHUB_PAT=$GITHUB_PAT --restart unless-stopped nullinside-cicd-github:latest
1+
docker compose build
2+
docker compose down
3+
docker compose up -d

src/Nullinside.Cicd.GitHub/Nullinside.Cicd.GitHub.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
9+
<LangVersion>default</LangVersion>
910
</PropertyGroup>
1011

1112
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

src/Nullinside.Cicd.GitHub/Program.cs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,30 @@
1818
.Where(o => null != o)
1919
.ToArray();
2020

21-
var client = new GitHubClient(new ProductHeaderValue("nullinside")) {
22-
Credentials = new Credentials(Environment.GetEnvironmentVariable("GITHUB_PAT"))
23-
};
24-
25-
var graphQl = new Connection(new Octokit.GraphQL.ProductHeaderValue("nullinside"),
26-
Environment.GetEnvironmentVariable("GITHUB_PAT"));
27-
28-
ID projectId = await graphQl.Run(new Query()
29-
.Organization(Constants.GITHUB_ORG)
30-
.ProjectV2(Constants.GITHUB_PROJECT_NUM)
31-
.Select(p => p.Id));
32-
33-
IReadOnlyList<Repository>? repository = await client.Repository.GetAllForOrg(Constants.GITHUB_ORG);
34-
foreach (Repository repo in repository) {
35-
if (repo.Private) {
36-
continue;
21+
while (true) {
22+
var client = new GitHubClient(new ProductHeaderValue("nullinside")) {
23+
Credentials = new Credentials(Environment.GetEnvironmentVariable("GITHUB_PAT"))
24+
};
25+
26+
var graphQl = new Connection(new Octokit.GraphQL.ProductHeaderValue("nullinside"),
27+
Environment.GetEnvironmentVariable("GITHUB_PAT"));
28+
29+
ID projectId = await graphQl.Run(new Query()
30+
.Organization(Constants.GITHUB_ORG)
31+
.ProjectV2(Constants.GITHUB_PROJECT_NUM)
32+
.Select(p => p.Id));
33+
34+
IReadOnlyList<Repository>? repository = await client.Repository.GetAllForOrg(Constants.GITHUB_ORG);
35+
foreach (Repository repo in repository) {
36+
if (repo.Private) {
37+
continue;
38+
}
39+
40+
foreach (IRepoRule? rule in rules) {
41+
await rule.Handle(client, graphQl, projectId, repo);
42+
}
3743
}
3844

39-
foreach (IRepoRule? rule in rules) {
40-
await rule.Handle(client, graphQl, projectId, repo);
41-
}
45+
Console.WriteLine("Waiting for next execution time...");
46+
Task.WaitAll(Task.Delay(TimeSpan.FromMinutes(5)));
4247
}

0 commit comments

Comments
 (0)