Skip to content

Commit

Permalink
Merge branch 'master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangiebel committed Sep 20, 2023
2 parents 7672337 + f6fdf84 commit 81a485f
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 27 deletions.
23 changes: 1 addition & 22 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
name: Build & Test

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -24,25 +22,6 @@ jobs:
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
build-upload-debug-files:
if: github.event_name == 'push' && github.event.push.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore -c Release -p:SentryOrg=sentry -p:SentryProject=ss14-map-server -p:SentryUploadSymbols=true -p:SentryUploadSources=true -p:SentryUrl=https://bugs.tanukij.dev
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Test
run: dotnet test --no-build --verbosity normal
ci-success:
name: Build & Test Debug
needs:
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/deploy-dev-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Dev Deploy

on:
workflow_dispatch:
branches:
- development

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
deploy-sentry:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore -c Release -p:SentryOrg=sentry -p:SentryProject=ss14-map-server -p:SentryUploadSymbols=true -p:SentryUploadSources=true -p:SentryUrl=https://bugs.tanukij.dev
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

deploy-container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:

- name: Docker Login
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v3
with:
submodules: recursive

- name: get-net-sdk-project-versions-action
uses: kzrnm/[email protected]
id: get-version
with:
proj-path: SS14.MapServer/SS14.MapServer.csproj

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=development
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

ci-success:
name: Deploy finished
needs:
- deploy-sentry
- deploy-container
runs-on: ubuntu-latest
steps:
- name: CI succeeded
run: exit 0
82 changes: 82 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Deploy

on:
push:
branches: [ "master" ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
deploy-sentry:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore -c Release -p:SentryOrg=sentry -p:SentryProject=ss14-map-server -p:SentryUploadSymbols=true -p:SentryUploadSources=true -p:SentryUrl=https://bugs.tanukij.dev
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

deploy-container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:

- name: Docker Login
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v3
with:
submodules: recursive

- name: get-net-sdk-project-versions-action
uses: kzrnm/[email protected]
id: get-version
with:
proj-path: SS14.MapServer/SS14.MapServer.csproj

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=raw,value=${{steps.get-version.outputs.version}}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

ci-success:
name: Deploy finished
needs:
- deploy-sentry
- deploy-container
runs-on: ubuntu-latest
steps:
- name: CI succeeded
run: exit 0
2 changes: 1 addition & 1 deletion SS14.MapServer/Services/FileManagementService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private Task<int> InternalCleanBuildDirectories()
foreach (var directory in poolDirectory.GetDirectories())
{
var files = _processingConfiguration.JunkFilePatterns
.SelectMany(pattern => directory.EnumerateFiles(pattern, SearchOption.AllDirectories));
.SelectMany(pattern => directory.EnumerateFiles(pattern, SearchOption.TopDirectoryOnly));

foreach (var file in files)
{
Expand Down
12 changes: 8 additions & 4 deletions SS14.MapServer/Services/GitService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LibGit2Sharp;
using LibGit2Sharp.Handlers;
using Serilog;
using SS14.MapServer.BuildRunners;
using SS14.MapServer.Configuration;
Expand Down Expand Up @@ -38,13 +39,11 @@ public string Sync(string workingDirectory, string? gitRef = null, string? repoU
if (!Path.IsPathRooted(repoDirectory))
repoDirectory = Path.Join(Directory.GetCurrentDirectory(), repoDirectory);


if (!Directory.Exists(repoDirectory))
Clone(repoUrl, repoDirectory, gitRef);

Pull(repoDirectory, gitRef);


return repoDirectory;
}

Expand Down Expand Up @@ -96,14 +95,19 @@ private void Pull(string repoDirectory, string gitRef)
_log.Debug("Opening repository in: {RepositoryPath}", repoDirectory);

using var repository = new Repository(repoDirectory);
//Set a dummy identity
_log.Debug("Setting identity");
repository.Config.Set("user.name", "ss14.mapserver");
repository.Config.Set("user.email", "[email protected]");

_log.Debug("Fetching ref");
_buildService.Run(repoDirectory, "git", new List<string> { "fetch origin", gitRef }).Wait();
_buildService.Run(repoDirectory, "git", new List<string> { "fetch -fu origin", gitRef }).Wait();

_log.Debug("Checking out {Ref}", StripRef(gitRef));
Commands.Checkout(repository, StripRef(gitRef));

_log.Debug("Pulling latest changes");
_buildService.Run(repoDirectory, "git", new List<string> { "pull origin HEAD" }).Wait();
_buildService.Run(repoDirectory, "git", new List<string> { "pull origin HEAD --ff-only" }).Wait();

_log.Debug("Updating submodules");
foreach (var submodule in repository.Submodules)
Expand Down

0 comments on commit 81a485f

Please sign in to comment.