forked from auqw/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (108 loc) · 4.34 KB
/
scriptsjson-generator.yaml
File metadata and controls
130 lines (108 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# name: Run Auto Generate JSON with C# File
# # === Workflow Trigger ===
# on:
# push:
# branches:
# - main
# - master
# - Skua
# - dev
# - 'feature/*'
# # === Job Definition ===
# jobs:
# run-csharp-file:
# runs-on: ubuntu-latest # The job will run on the latest version of Ubuntu
# steps:
# # === Step: Checkout Code ===
# - name: Checkout code
# uses: actions/checkout@v4.2.2 # Checks out the repository code
# # === Step: Cache NuGet Packages ===
# - name: Cache NuGet packages
# uses: actions/cache@v4.2.0 # Caches NuGet packages to speed up builds
# with:
# path: ~/.nuget/packages # Path to the NuGet package cache
# key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.cs') }} # Cache key based on OS and project files
# restore-keys: |
# ${{ runner.os }}-nuget- # Restore keys for cache
# # === Step: Setup .NET ===
# - name: Setup .NET Core SDK
# uses: actions/setup-dotnet@v4.2.0 # Sets up the .NET environment
# with:
# dotnet-version: '6.0.x' # Specifies the .NET version to use
# # === Step: Build the Project ===
# - name: Build the project
# run: dotnet build --configuration Release SkuaScriptsGenerator/SkuaScriptsGenerator.csproj # Builds the project in Release mode
# # === Step: Run C# File ===
# - name: Run C# file
# run: dotnet run --project SkuaScriptsGenerator/SkuaScriptsGenerator.csproj > scripts.json # Runs the C# program and outputs to scripts.json
# # === Step: Upload Artifact ===
# - name: Upload artifact
# uses: actions/upload-artifact@v4.6.0 # Uploads the generated artifact
# with:
# name: scripts-${{ github.run_id }}.json # Names the artifact with the run ID for uniqueness
# path: scripts.json # Path to the file to upload
# retention-days: 30 # Keeps the artifact for 30 days
# # === Step: Commit and Push Changes ===
# - name: Git Auto Commit
# uses: stefanzweifel/git-auto-commit-action@v5.1.0
# with:
# commit_message: 'Automatic commit by GitHub Actions' # Custom commit message
# file_pattern: 'scripts.json' # File(s) to include in the commit
# push_options: '--force' # Force push to override remote changes
# branch: '${{ github.ref_name }}' # Dynamically use the current branch
# skip_dirty_check: true # Skip the dirty check to always commit
# old ^^
name: Run Auto Generate JSON with C# File
# === Workflow Triggers ===
on:
push:
branches:
- main
- master
- Skua
- dev
- 'feature/*'
# === Job Definition ===
jobs:
run-csharp-file:
runs-on: ubuntu-latest
steps:
# === Step: Checkout Code ===
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Configure git to preserve line endings
run: git config --global core.autocrlf false
# === Step: Cache NuGet Packages ===
- name: Cache NuGet packages
uses: actions/cache@v4.2.0
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.cs') }}
restore-keys: |
${{ runner.os }}-nuget-
# === Step: Setup .NET ===
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4.2.0
with:
dotnet-version: '8.0.x'
# === Step: Build the Project ===
- name: Build the project
run: dotnet build --configuration Release SkuaScriptsGenerator/SkuaScriptsGenerator.csproj
# === Step: Run C# File ===
- name: Run C# file
run: dotnet run --project SkuaScriptsGenerator/SkuaScriptsGenerator.csproj 2>/dev/null > scripts.json
# === Step: Upload Artifact (only if changes are detected) ===
- name: Upload artifact
uses: actions/upload-artifact@v4.6.0
with:
name: scripts-${{ github.run_id }}.json
path: scripts.json
retention-days: 60
# === Step: Commit and Push Changes (only if changes are detected) ===
- name: Git Auto Commit
uses: stefanzweifel/git-auto-commit-action@v5.1.0
with:
commit_message: 'Automatic commit by GitHub Actions'
file_pattern: 'scripts.json'
push_options: '--force'
branch: '${{ github.ref_name }}'