├── .editorconfig
├── .gitignore
├── .vscode
├── extensions.json
├── launch.json
├── settings.json
└── tasks.json
├── LICENSE
├── README.md
├── SampleApp.sln
├── api.zip
├── api
├── .gitignore
├── ApiApp.csproj
├── Function1.cs
├── OpenApiConfigurationOptions.cs
├── Properties
│ ├── serviceDependencies.json
│ └── serviceDependencies.local.json
├── host.json
└── local.settings.sample.json
├── global.json
├── step-01.md
├── step-02.md
├── step-03.md
├── step-04.md
├── step-05.md
├── step-06.md
└── step-07.md
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: https://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | [*]
7 | indent_style = space
8 | indent_size = 4
9 | end_of_line = lf
10 | charset = utf-8
11 | trim_trailing_whitespace = false
12 | insert_final_newline = false
13 |
14 | [*.{json,yml,yaml}]
15 | indent_size = 2
16 |
17 | [*.{csproj}]
18 | indent_size = 2
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
352 | .DS_Store
353 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "ms-azuretools.vscode-azurefunctions",
4 | "ms-dotnettools.csharp"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "Attach to .NET Functions",
6 | "type": "coreclr",
7 | "request": "attach",
8 | "processId": "${command:azureFunctions.pickProcess}"
9 | }
10 | ]
11 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "azureFunctions.deploySubpath": "api/bin/Release/net6.0/publish",
3 | "azureFunctions.projectLanguage": "C#",
4 | "azureFunctions.projectRuntime": "~4",
5 | "debug.internalConsoleOptions": "neverOpen",
6 | "azureFunctions.preDeployTask": "publish (functions)"
7 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "clean (functions)",
6 | "command": "dotnet",
7 | "args": [
8 | "clean",
9 | "/property:GenerateFullPaths=true",
10 | "/consoleloggerparameters:NoSummary"
11 | ],
12 | "type": "process",
13 | "problemMatcher": "$msCompile",
14 | "options": {
15 | "cwd": "${workspaceFolder}/api"
16 | }
17 | },
18 | {
19 | "label": "build (functions)",
20 | "command": "dotnet",
21 | "args": [
22 | "build",
23 | "/property:GenerateFullPaths=true",
24 | "/consoleloggerparameters:NoSummary"
25 | ],
26 | "type": "process",
27 | "dependsOn": "clean (functions)",
28 | "group": {
29 | "kind": "build",
30 | "isDefault": true
31 | },
32 | "problemMatcher": "$msCompile",
33 | "options": {
34 | "cwd": "${workspaceFolder}/api"
35 | }
36 | },
37 | {
38 | "label": "clean release (functions)",
39 | "command": "dotnet",
40 | "args": [
41 | "clean",
42 | "--configuration",
43 | "Release",
44 | "/property:GenerateFullPaths=true",
45 | "/consoleloggerparameters:NoSummary"
46 | ],
47 | "type": "process",
48 | "problemMatcher": "$msCompile",
49 | "options": {
50 | "cwd": "${workspaceFolder}/api"
51 | }
52 | },
53 | {
54 | "label": "publish (functions)",
55 | "command": "dotnet",
56 | "args": [
57 | "publish",
58 | "--configuration",
59 | "Release",
60 | "/property:GenerateFullPaths=true",
61 | "/consoleloggerparameters:NoSummary"
62 | ],
63 | "type": "process",
64 | "dependsOn": "clean release (functions)",
65 | "problemMatcher": "$msCompile",
66 | "options": {
67 | "cwd": "${workspaceFolder}/api"
68 | }
69 | },
70 | {
71 | "type": "func",
72 | "dependsOn": "build (functions)",
73 | "options": {
74 | "cwd": "${workspaceFolder}/api/bin/Debug/net6.0"
75 | },
76 | "command": "host start",
77 | "isBackground": true,
78 | "problemMatcher": "$func-dotnet-watch"
79 | }
80 | ]
81 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Dev Kimchi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GitHub Actions from Scratch #
2 |
3 | This provides step-by-step approach learning GitHub Actions.
4 |
5 |
6 | ## Prerequisites ##
7 |
8 | * [Git SCM](https://git-scm.com/)
9 | * [Visual Studio Code](https://code.visualstudio.com/?WT.mc_id=dotnet-68779-juyoo)
10 | * [PowerShell](https://docs.microsoft.com/powershell/scripting/overview?WT.mc_id=dotnet-68779-juyoo)
11 | * [Azure CLI](https://docs.microsoft.com/cli/azure/what-is-azure-cli?WT.mc_id=dotnet-68779-juyoo)
12 | * [GitHub CLI](https://cli.github.com/)
13 | * [Docker Desktop](https://docs.docker.com/get-docker/)
14 |
15 |
16 | ## Steps ##
17 |
18 | 1. [Local Development Environment Setup](./step-01.md)
19 | 2. [Basic Syntax](./step-02.md)
20 | 3. [Matrix & Conditions](./step-03.md)
21 | 4. [Events & Refactoring](./step-04.md)
22 | 5. [Multi-Stage Deployments](./step-05.md)
23 |
24 |
25 | ## Further Reading ##
26 |
27 | * [Microsoft Learn](https://docs.microsoft.com/learn/?WT.mc_id=dotnet-68779-juyoo): [GitHub Actions](https://docs.microsoft.com/learn/paths/automate-workflow-github-actions/?WT.mc_id=dotnet-68779-juyoo)
28 | * [Microsoft Developer Korea](http://youtube.com/microsoftdeveloperkorea): [GitHub Actions로 개발 주기 자동화 | 애저 듣보잡](https://www.youtube.com/watch?v=MhGpFunlmMQ&list=PLDZRZwFT9Wkt19Ox35Ir2A7CyNIWG96Nm) (Korean)
29 | * [Microsoft Developer Korea](http://youtube.com/microsoftdeveloperkorea): [GitHub Actions 이런 것도 할 수 있다고? | 애저 한발짝](https://aka.ms/az1s/ep2) (Korean)
30 | * [아웃사이더 블로그](https://blog.outsider.ne.kr/): [GitHub Actions 관련 포스트 모음](https://blog.outsider.ne.kr/search?q=github%20actions) (Korean)
31 |
--------------------------------------------------------------------------------
/SampleApp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.1.32319.34
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiApp", "api\ApiApp.csproj", "{F05EF42D-7559-491B-9E79-96BC78B748B0}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {F05EF42D-7559-491B-9E79-96BC78B748B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {F05EF42D-7559-491B-9E79-96BC78B748B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {F05EF42D-7559-491B-9E79-96BC78B748B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {F05EF42D-7559-491B-9E79-96BC78B748B0}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {56FEFF0C-A941-46C4-B7D4-A96384C44B1F}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/api.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devkimchi/github-actions-from-scratch/5b9070bc2b6fb44c7a607fb2c9c4e48809a14832/api.zip
--------------------------------------------------------------------------------
/api/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # Azure Functions localsettings file
5 | local.settings.json
6 |
7 | # User-specific files
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | bld/
24 | [Bb]in/
25 | [Oo]bj/
26 | [Ll]og/
27 |
28 | # Visual Studio 2015 cache/options directory
29 | .vs/
30 | # Uncomment if you have tasks that create the project's static files in wwwroot
31 | #wwwroot/
32 |
33 | # MSTest test Results
34 | [Tt]est[Rr]esult*/
35 | [Bb]uild[Ll]og.*
36 |
37 | # NUNIT
38 | *.VisualState.xml
39 | TestResult.xml
40 |
41 | # Build Results of an ATL Project
42 | [Dd]ebugPS/
43 | [Rr]eleasePS/
44 | dlldata.c
45 |
46 | # DNX
47 | project.lock.json
48 | project.fragment.lock.json
49 | artifacts/
50 |
51 | *_i.c
52 | *_p.c
53 | *_i.h
54 | *.ilk
55 | *.meta
56 | *.obj
57 | *.pch
58 | *.pdb
59 | *.pgc
60 | *.pgd
61 | *.rsp
62 | *.sbr
63 | *.tlb
64 | *.tli
65 | *.tlh
66 | *.tmp
67 | *.tmp_proj
68 | *.log
69 | *.vspscc
70 | *.vssscc
71 | .builds
72 | *.pidb
73 | *.svclog
74 | *.scc
75 |
76 | # Chutzpah Test files
77 | _Chutzpah*
78 |
79 | # Visual C++ cache files
80 | ipch/
81 | *.aps
82 | *.ncb
83 | *.opendb
84 | *.opensdf
85 | *.sdf
86 | *.cachefile
87 | *.VC.db
88 | *.VC.VC.opendb
89 |
90 | # Visual Studio profiler
91 | *.psess
92 | *.vsp
93 | *.vspx
94 | *.sap
95 |
96 | # TFS 2012 Local Workspace
97 | $tf/
98 |
99 | # Guidance Automation Toolkit
100 | *.gpState
101 |
102 | # ReSharper is a .NET coding add-in
103 | _ReSharper*/
104 | *.[Rr]e[Ss]harper
105 | *.DotSettings.user
106 |
107 | # JustCode is a .NET coding add-in
108 | .JustCode
109 |
110 | # TeamCity is a build add-in
111 | _TeamCity*
112 |
113 | # DotCover is a Code Coverage Tool
114 | *.dotCover
115 |
116 | # NCrunch
117 | _NCrunch_*
118 | .*crunch*.local.xml
119 | nCrunchTemp_*
120 |
121 | # MightyMoose
122 | *.mm.*
123 | AutoTest.Net/
124 |
125 | # Web workbench (sass)
126 | .sass-cache/
127 |
128 | # Installshield output folder
129 | [Ee]xpress/
130 |
131 | # DocProject is a documentation generator add-in
132 | DocProject/buildhelp/
133 | DocProject/Help/*.HxT
134 | DocProject/Help/*.HxC
135 | DocProject/Help/*.hhc
136 | DocProject/Help/*.hhk
137 | DocProject/Help/*.hhp
138 | DocProject/Help/Html2
139 | DocProject/Help/html
140 |
141 | # Click-Once directory
142 | publish/
143 |
144 | # Publish Web Output
145 | *.[Pp]ublish.xml
146 | *.azurePubxml
147 | # TODO: Comment the next line if you want to checkin your web deploy settings
148 | # but database connection strings (with potential passwords) will be unencrypted
149 | #*.pubxml
150 | *.publishproj
151 |
152 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
153 | # checkin your Azure Web App publish settings, but sensitive information contained
154 | # in these scripts will be unencrypted
155 | PublishScripts/
156 |
157 | # NuGet Packages
158 | *.nupkg
159 | # The packages folder can be ignored because of Package Restore
160 | **/packages/*
161 | # except build/, which is used as an MSBuild target.
162 | !**/packages/build/
163 | # Uncomment if necessary however generally it will be regenerated when needed
164 | #!**/packages/repositories.config
165 | # NuGet v3's project.json files produces more ignoreable files
166 | *.nuget.props
167 | *.nuget.targets
168 |
169 | # Microsoft Azure Build Output
170 | csx/
171 | *.build.csdef
172 |
173 | # Microsoft Azure Emulator
174 | ecf/
175 | rcf/
176 |
177 | # Windows Store app package directories and files
178 | AppPackages/
179 | BundleArtifacts/
180 | Package.StoreAssociation.xml
181 | _pkginfo.txt
182 |
183 | # Visual Studio cache files
184 | # files ending in .cache can be ignored
185 | *.[Cc]ache
186 | # but keep track of directories ending in .cache
187 | !*.[Cc]ache/
188 |
189 | # Others
190 | ClientBin/
191 | ~$*
192 | *~
193 | *.dbmdl
194 | *.dbproj.schemaview
195 | *.jfm
196 | *.pfx
197 | *.publishsettings
198 | node_modules/
199 | orleans.codegen.cs
200 |
201 | # Since there are multiple workflows, uncomment next line to ignore bower_components
202 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
203 | #bower_components/
204 |
205 | # RIA/Silverlight projects
206 | Generated_Code/
207 |
208 | # Backup & report files from converting an old project file
209 | # to a newer Visual Studio version. Backup files are not needed,
210 | # because we have git ;-)
211 | _UpgradeReport_Files/
212 | Backup*/
213 | UpgradeLog*.XML
214 | UpgradeLog*.htm
215 |
216 | # SQL Server files
217 | *.mdf
218 | *.ldf
219 |
220 | # Business Intelligence projects
221 | *.rdl.data
222 | *.bim.layout
223 | *.bim_*.settings
224 |
225 | # Microsoft Fakes
226 | FakesAssemblies/
227 |
228 | # GhostDoc plugin setting file
229 | *.GhostDoc.xml
230 |
231 | # Node.js Tools for Visual Studio
232 | .ntvs_analysis.dat
233 |
234 | # Visual Studio 6 build log
235 | *.plg
236 |
237 | # Visual Studio 6 workspace options file
238 | *.opt
239 |
240 | # Visual Studio LightSwitch build output
241 | **/*.HTMLClient/GeneratedArtifacts
242 | **/*.DesktopClient/GeneratedArtifacts
243 | **/*.DesktopClient/ModelManifest.xml
244 | **/*.Server/GeneratedArtifacts
245 | **/*.Server/ModelManifest.xml
246 | _Pvt_Extensions
247 |
248 | # Paket dependency manager
249 | .paket/paket.exe
250 | paket-files/
251 |
252 | # FAKE - F# Make
253 | .fake/
254 |
255 | # JetBrains Rider
256 | .idea/
257 | *.sln.iml
258 |
259 | # CodeRush
260 | .cr/
261 |
262 | # Python Tools for Visual Studio (PTVS)
263 | __pycache__/
264 | *.pyc
--------------------------------------------------------------------------------
/api/ApiApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | v4
6 |
7 | ApiApp
8 | ApiApp
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | PreserveNewest
19 |
20 |
21 | PreserveNewest
22 | Never
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/api/Function1.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Net;
3 | using System.Threading.Tasks;
4 |
5 | using Microsoft.AspNetCore.Http;
6 | using Microsoft.AspNetCore.Mvc;
7 | using Microsoft.Azure.WebJobs;
8 | using Microsoft.Azure.WebJobs.Extensions.Http;
9 | using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes;
10 | using Microsoft.Extensions.Logging;
11 | using Microsoft.OpenApi.Models;
12 |
13 | using Newtonsoft.Json;
14 |
15 | namespace Swm.ApiApp
16 | {
17 | public class Function1
18 | {
19 | private readonly ILogger _logger;
20 |
21 | public Function1(ILogger log)
22 | {
23 | _logger = log;
24 | }
25 |
26 | [FunctionName("Function1")]
27 | [OpenApiOperation(operationId: "Run", tags: new[] { "name" })]
28 | [OpenApiParameter(name: "name", In = ParameterLocation.Query, Required = true, Type = typeof(string), Description = "The **Name** parameter")]
29 | [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "text/plain", bodyType: typeof(string), Description = "The OK response")]
30 | public async Task Run(
31 | [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "ping")] HttpRequest req)
32 | {
33 | _logger.LogInformation("C# HTTP trigger function processed a request.");
34 |
35 | string name = req.Query["name"];
36 |
37 | string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
38 | dynamic data = JsonConvert.DeserializeObject(requestBody);
39 | name = name ?? data?.name;
40 |
41 | string responseMessage = string.IsNullOrEmpty(name)
42 | ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
43 | : $"Hello, {name}. This HTTP triggered function executed successfully.";
44 |
45 | return new OkObjectResult(responseMessage);
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/api/OpenApiConfigurationOptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations;
8 | using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums;
9 |
10 | namespace Swm.ApiApp
11 | {
12 | public class OpenApiConfigurationOptions : DefaultOpenApiConfigurationOptions
13 | {
14 | public override OpenApiVersionType OpenApiVersion { get; set; } = OpenApiVersionType.V3;
15 | public override bool IncludeRequestingHostName { get; set; } = false;
16 | }
17 | }
--------------------------------------------------------------------------------
/api/Properties/serviceDependencies.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "appInsights1": {
4 | "type": "appInsights"
5 | },
6 | "storage1": {
7 | "type": "storage",
8 | "connectionId": "AzureWebJobsStorage"
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/api/Properties/serviceDependencies.local.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "storage1": {
4 | "type": "storage.emulator",
5 | "connectionId": "AzureWebJobsStorage"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/api/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "logging": {
4 | "applicationInsights": {
5 | "samplingSettings": {
6 | "isEnabled": true,
7 | "excludedTypes": "Request"
8 | }
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/api/local.settings.sample.json:
--------------------------------------------------------------------------------
1 | {
2 | "IsEncrypted": false,
3 | "Values": {
4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true",
5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet",
6 |
7 | "OpenApi__Version": "v3",
8 | "OpenApi__DocTitle": "Sample API App"
9 | }
10 | }
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "allowPrerelease": false
4 | }
5 | }
--------------------------------------------------------------------------------
/step-01.md:
--------------------------------------------------------------------------------
1 | # Local Development Environment Setup #
2 |
3 | ## Install git ##
4 |
5 | * [For Windows](https://git-scm.com/download/win)
6 | * [For Mac](https://git-scm.com/download/mac)
7 | * [For Linux](https://git-scm.com/download/linux)
8 |
9 |
10 | ## Install Visual Studio Code ##
11 |
12 | * [Visual Studio Code](https://code.visualstudio.com/?WT.mc_id=dotnet-68779-juyoo#alt-downloads)
13 |
14 |
15 | ## Install PowerShell ##
16 |
17 | * [PowerShell](https://docs.microsoft.com/powershell/scripting/install/installing-powershell?WT.mc_id=dotnet-68779-juyoo)
18 |
19 |
20 | ## Install Azure CLI ##
21 |
22 | * [Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli?WT.mc_id=dotnet-68779-juyoo)
23 |
24 |
25 | ## Install GitHub CLI ##
26 |
27 | * [GitHub CLI](https://github.com/cli/cli#installation)
28 |
29 |
30 | ## Install Docker Desktop ##
31 |
32 | * [Docker Desktop](https://docs.docker.com/get-docker/)
33 |
34 | > Docker Desktop is free for personal use.
35 |
36 |
--------------------------------------------------------------------------------
/step-02.md:
--------------------------------------------------------------------------------
1 | # Basic Syntax #
2 |
3 | ## `main.yaml` ##
4 |
5 | ```yaml
6 | name: 'My First GitHub Actions'
7 |
8 | on: push
9 |
10 | jobs:
11 | first-job:
12 | name: 'First Job'
13 |
14 | runs-on: ubuntu-latest
15 |
16 | steps:
17 | - name: Say Hello World 1
18 | shell: bash
19 | run: |
20 | echo "Hello World from step 1"
21 |
22 | - name: Say Hello World 2
23 | shell: pwsh
24 | run: |
25 | echo "Hello World from step 2"
26 | ```
27 |
28 |
29 | ## Environment Variables ##
30 |
31 | ```yaml
32 | name: 'My First GitHub Actions'
33 |
34 | on: push
35 |
36 | env:
37 | WORKFLOW_LEVEL: "This value comes from the WORKFLOW level"
38 |
39 | jobs:
40 | first-job:
41 | name: 'First Job'
42 |
43 | runs-on: ubuntu-latest
44 |
45 | env:
46 | JOB_LEVEL: "This value comes from the JOB level"
47 |
48 | steps:
49 | - name: Say Hello World
50 | shell: bash
51 | run: |
52 | echo "Hello World"
53 |
54 | - name: Check environment variables 1
55 | shell: bash
56 | env:
57 | STEP_LEVEL_1: "This value comes from the STEP level #1"
58 | run: |
59 | echo "workflow level: $WORKFLOW_LEVEL"
60 | echo "job level: $JOB_LEVEL"
61 | echo "step level 1: $STEP_LEVEL_1"
62 | echo "step level 2: $STEP_LEVEL_2"
63 | echo "step level 3: $STEP_LEVEL_3"
64 |
65 | - name: Check environment variables 2
66 | shell: pwsh
67 | env:
68 | STEP_LEVEL_2: "This value comes from the STEP level #2"
69 | run: |
70 | echo "workflow level: $env:WORKFLOW_LEVEL"
71 | echo "job level: $env:JOB_LEVEL"
72 | echo "step level 1: $env:STEP_LEVEL_1"
73 | echo "step level 2: $env:STEP_LEVEL_2"
74 | echo "step level 3: $env:STEP_LEVEL_3"
75 |
76 | - name: Check environment variables 3
77 | shell: bash
78 | env:
79 | STEP_LEVEL_3: "This value comes from the STEP level #3"
80 | run: |
81 | echo "workflow level: ${{ env.WORKFLOW_LEVEL }}"
82 | echo "job level: ${{ env.JOB_LEVEL }}"
83 | echo "step level 1: ${{ env.STEP_LEVEL_1 }}"
84 | echo "step level 2: ${{ env.STEP_LEVEL_2 }}"
85 | echo "step level 3: ${{ env.STEP_LEVEL_3 }}"
86 | ```
87 |
88 |
89 | ## Runtime Environment Variables ##
90 |
91 | ```yaml
92 | name: 'My First GitHub Actions'
93 |
94 | on: push
95 |
96 | env:
97 | PRESET_VALUE: "This is the preset value"
98 |
99 | jobs:
100 | first-job:
101 | name: 'First Job'
102 |
103 | runs-on: ubuntu-latest
104 |
105 | steps:
106 | - name: Set environment variable 1
107 | shell: bash
108 | run: |
109 | echo "STEPSET_VALUE_1='This is the value 1 set in the step'" >> $GITHUB_ENV
110 |
111 | - name: Set environment variable 2
112 | shell: pwsh
113 | run: |
114 | echo "STEPSET_VALUE_2='This is the value 2 set in the step'" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append
115 |
116 | - name: Check environment variables
117 | shell: bash
118 | run: |
119 | echo "preset value: ${{ env.PRESET_VALUE }}"
120 | echo "stepset value 1: ${{ env.STEPSET_VALUE_1 }}"
121 | echo "stepset value 2: ${{ env.STEPSET_VALUE_2 }}"
122 | ```
123 |
124 |
125 | ## Output Values Reference ##
126 |
127 | ```yaml
128 | name: 'My First GitHub Actions'
129 |
130 | on: push
131 |
132 | jobs:
133 | first-job:
134 | name: 'First Job'
135 |
136 | runs-on: ubuntu-latest
137 |
138 | steps:
139 | - name: Set output value
140 | id: first
141 | shell: bash
142 | run: |
143 | first_value="This is the value for the first output"
144 |
145 | echo "::set-output name=first_value::$first_value"
146 |
147 | - name: Check output value
148 | shell: bash
149 | run: |
150 | echo "first value: ${{ steps.first.outputs.first_value }}"
151 | ```
152 |
153 |
154 | ## Output Values Mask ##
155 |
156 | ```yaml
157 | name: 'My First GitHub Actions'
158 |
159 | on: push
160 |
161 | jobs:
162 | first-job:
163 | name: 'First Job'
164 |
165 | runs-on: ubuntu-latest
166 |
167 | steps:
168 | - name: Mask output value
169 | id: first
170 | shell: bash
171 | run: |
172 | first_value="This is the value for the first output"
173 |
174 | echo "::add-mask::$first_value"
175 | echo "::set-output name=first_value::$first_value"
176 |
177 | - name: Check output value
178 | shell: bash
179 | run: |
180 | echo "first value: ${{ steps.first.outputs.first_value }}"
181 | ```
182 |
183 |
184 | ## GitHub Secrets ##
185 |
186 | ```yaml
187 | name: 'My First GitHub Actions'
188 |
189 | on: push
190 |
191 | jobs:
192 | first-job:
193 | name: 'First Job'
194 |
195 | runs-on: ubuntu-latest
196 |
197 | steps:
198 | - name: Show secret
199 | shell: bash
200 | run: |
201 | echo ${{ secrets.HELLO }}
202 |
203 | - name: Check secret
204 | shell: pwsh
205 | run: |
206 | if ("${{ secrets.HELLO }}" -eq "World") {
207 | echo "YES!"
208 | } else {
209 | echo "NO!"
210 | }
211 | ```
212 |
--------------------------------------------------------------------------------
/step-03.md:
--------------------------------------------------------------------------------
1 | # Matrix & Conditions #
2 |
3 | ## Matrix #1 ##
4 |
5 | ```yaml
6 | name: 'My First GitHub Actions'
7 |
8 | on: push
9 |
10 | jobs:
11 | first-job:
12 | name: 'First Job'
13 |
14 | strategy:
15 | matrix:
16 | os: [ 'windows-latest', 'macos-latest', 'ubuntu-latest' ]
17 |
18 | runs-on: ${{ matrix.os }}
19 |
20 | steps:
21 | - name: Say Hello World on ${{ matrix.os }}
22 | shell: bash
23 | run: |
24 | echo "Hello World on ${{ matrix.os }}"
25 | ```
26 |
27 |
28 | ## Matrix #2 ##
29 |
30 | ```yaml
31 | name: 'My First GitHub Actions'
32 |
33 | on: push
34 |
35 | jobs:
36 | first-job:
37 | name: 'First Job'
38 |
39 | strategy:
40 | matrix:
41 | os: [ 'windows-latest', 'macos-latest', 'ubuntu-latest' ]
42 | message: [ 'Hello World', 'Lorem Ipsum' ]
43 |
44 | runs-on: ${{ matrix.os }}
45 |
46 | steps:
47 | - name: Greetings from ${{ matrix.os }}
48 | shell: bash
49 | run: |
50 | echo "${{ matrix.message }} from ${{ matrix.os }}"
51 | ```
52 |
53 |
54 | ## Matrix #3 ##
55 |
56 | ```yaml
57 | name: 'My First GitHub Actions'
58 |
59 | on: push
60 |
61 | jobs:
62 | first-job:
63 | name: 'First Job'
64 |
65 | strategy:
66 | matrix:
67 | os: [ 'windows-latest', 'macos-latest', 'ubuntu-latest' ]
68 | nodejs: [ '14.x', '16.x' ]
69 |
70 | runs-on: ${{ matrix.os }}
71 |
72 | steps:
73 | - name: Setup node.js
74 | uses: actions/setup-node@v3
75 | with:
76 | node-version: ${{ matrix.nodejs }}
77 |
78 | - name: Check node.js version from ${{ matrix.os }}
79 | shell: bash
80 | run: |
81 | echo $(node --version)
82 | ```
83 |
84 |
85 | ## Conditions on Jobs ##
86 |
87 | ```yaml
88 | name: 'My First GitHub Actions'
89 |
90 | on: [ 'push', 'pull_request' ]
91 |
92 | jobs:
93 | first-job:
94 | name: 'First Job'
95 | if: github.event_name == 'push'
96 |
97 | strategy:
98 | matrix:
99 | os: [ 'windows-latest', 'macos-latest', 'ubuntu-latest' ]
100 |
101 | runs-on: ${{ matrix.os }}
102 |
103 | steps:
104 | - name: Say Hello World from ${{ matrix.os }}
105 | shell: bash
106 | run: |
107 | echo "Hello World on ${{ matrix.os }}"
108 |
109 | second-job:
110 | name: 'Second Job'
111 | if: github.event_name == 'pull_request'
112 |
113 | strategy:
114 | matrix:
115 | os: [ 'windows-latest', 'macos-latest', 'ubuntu-latest' ]
116 |
117 | runs-on: ${{ matrix.os }}
118 |
119 | steps:
120 | - name: Say Hello World from ${{ matrix.os }}
121 | shell: bash
122 | run: |
123 | echo "Hello World on ${{ matrix.os }}"
124 | ```
125 |
126 |
127 | ## Conditions on Steps ##
128 |
129 | ```yaml
130 | name: 'My First GitHub Actions'
131 |
132 | on: push
133 |
134 | jobs:
135 | first-job:
136 | name: 'First Job'
137 |
138 | strategy:
139 | matrix:
140 | os: [ 'windows-latest', 'macos-latest', 'ubuntu-latest' ]
141 |
142 | runs-on: ${{ matrix.os }}
143 |
144 | steps:
145 | - name: Say Hello World from ${{ matrix.os }} 1
146 | shell: bash
147 | run: |
148 | echo "Hello World on ${{ matrix.os }} 1"
149 |
150 | - name: Say Hello World from ${{ matrix.os }} 2
151 | if: matrix.os == 'ubuntu-latest'
152 | shell: bash
153 | run: |
154 | echo "Hello World on ${{ matrix.os }} 2"
155 | ```
156 |
157 |
158 | ## Job Chaining ##
159 |
160 | ```yaml
161 | name: 'My First GitHub Actions'
162 |
163 | on:
164 | push:
165 | branches:
166 | - main
167 |
168 | jobs:
169 | first-job:
170 | name: 'First Job'
171 |
172 | runs-on: ubuntu-latest
173 |
174 | steps:
175 | - name: Say Hello World from first job
176 | shell: bash
177 | run: |
178 | echo "Hello World from first job"
179 |
180 | second-job:
181 | name: 'Second Job'
182 | needs: first-job
183 |
184 | runs-on: ubuntu-latest
185 |
186 | steps:
187 | - name: Say Hello World from second job
188 | shell: bash
189 | run: |
190 | echo "Hello World from second job"
191 | ```
192 |
--------------------------------------------------------------------------------
/step-04.md:
--------------------------------------------------------------------------------
1 | # Events & Refactoring #
2 |
3 | ## Events – `push`, `pull_request` ##
4 |
5 | ```yaml
6 | name: 'My First GitHub Actions'
7 |
8 | on:
9 | push:
10 | branches:
11 | - main
12 | tags:
13 | - 'v*'
14 | pull_request:
15 | branches:
16 | - main
17 |
18 | jobs:
19 | build:
20 | name: Build Apps
21 |
22 | runs-on: ubuntu-latest
23 |
24 | steps:
25 | - name: Checkout the repo
26 | uses: actions/checkout@v2
27 |
28 | - name: Setup .NET SDK
29 | uses: actions/setup-dotnet@v1
30 | with:
31 | dotnet-version: '6.x'
32 |
33 | - name: Restore NuGet packages
34 | shell: bash
35 | run: |
36 | dotnet restore ./api
37 |
38 | - name: Build solution
39 | shell: bash
40 | run: |
41 | dotnet build ./api -c Release
42 |
43 | - name: Create FunctionApp artifact
44 | shell: bash
45 | run: |
46 | dotnet publish ./api -c Release -o ./api/bin/published
47 |
48 | - name: Upload FunctionApp artifact
49 | uses: actions/upload-artifact@v2
50 | with:
51 | name: apiapp
52 | path: api/bin/published
53 |
54 | release:
55 | name: Release Apps
56 | needs: build
57 |
58 | runs-on: ubuntu-latest
59 |
60 | steps:
61 | - name: Download FunctionApp artifact
62 | uses: actions/download-artifact@v2
63 | with:
64 | name: apiapp
65 | path: artifacts/api
66 |
67 | - name: Zip FunctionApp artifact
68 | shell: bash
69 | run: |
70 | pushd artifacts/api
71 | zip -qq -r apiapp.zip .
72 | popd
73 |
74 | mv artifacts/api/apiapp.zip artifacts/apiapp.zip
75 |
76 | - name: Release FunctionApp artifact to GitHub
77 | uses: "marvinpinto/action-automatic-releases@latest"
78 | with:
79 | repo_token: "${{ secrets.GITHUB_TOKEN }}"
80 | prerelease: false
81 | files: |
82 | artifacts/apiapp.zip
83 | ```
84 |
85 |
86 | ## Events – `workflow_dispatch` ##
87 |
88 | ```yaml
89 | name: 'Manual Release'
90 |
91 | on:
92 | workflow_dispatch:
93 | inputs:
94 | title:
95 | type: string
96 | required: true
97 | description: Enter the release title
98 |
99 | jobs:
100 | build:
101 | name: Build Apps
102 |
103 | runs-on: ubuntu-latest
104 |
105 | steps:
106 | - name: Checkout the repo
107 | uses: actions/checkout@v2
108 |
109 | - name: Setup .NET SDK
110 | uses: actions/setup-dotnet@v1
111 | with:
112 | dotnet-version: '6.x'
113 |
114 | - name: Restore NuGet packages
115 | shell: bash
116 | run: |
117 | dotnet restore ./api
118 |
119 | - name: Build solution
120 | shell: bash
121 | run: |
122 | dotnet build ./api -c Release
123 |
124 | - name: Create FunctionApp artifact
125 | shell: bash
126 | run: |
127 | dotnet publish ./api -c Release -o ./api/bin/published
128 |
129 | - name: Upload FunctionApp artifact
130 | uses: actions/upload-artifact@v2
131 | with:
132 | name: apiapp
133 | path: api/bin/published
134 |
135 | release:
136 | name: Release Apps
137 | needs: build
138 |
139 | runs-on: ubuntu-latest
140 |
141 | steps:
142 | - name: Download FunctionApp artifact
143 | uses: actions/download-artifact@v2
144 | with:
145 | name: apiapp
146 | path: artifacts/api
147 |
148 | - name: Zip FunctionApp artifact
149 | shell: bash
150 | run: |
151 | pushd artifacts/api
152 | zip -qq -r apiapp.zip .
153 | popd
154 |
155 | mv artifacts/api/apiapp.zip artifacts/apiapp.zip
156 |
157 | - name: Release FunctionApp artifact to GitHub
158 | uses: "marvinpinto/action-automatic-releases@latest"
159 | with:
160 | repo_token: "${{ secrets.GITHUB_TOKEN }}"
161 | prerelease: false
162 | title: ${{ github.event.inputs.title }}
163 | files: |
164 | artifacts/apiapp.zip
165 | ```
166 |
167 |
168 | ## Events – `workflow_call` ##
169 |
170 | ### `main.yaml` ###
171 |
172 | ```yaml
173 | name: 'My First GitHub Actions'
174 |
175 | on:
176 | push:
177 | branches:
178 | - main
179 | tags:
180 | - 'v*'
181 | pull_request:
182 | branches:
183 | - main
184 |
185 | jobs:
186 | call_build:
187 | uses: ./.github/workflows/ci.yaml
188 | with:
189 | artifact_name: apiapp
190 |
191 | call_release:
192 | uses: ./.github/worlfows/cd.yaml
193 | needs: call_build
194 | with:
195 | title: latest
196 | artifact_name: apiapp
197 | secrets: inherit
198 | ```
199 |
200 |
201 | ### `manual-release.yaml` ###
202 |
203 | ```yaml
204 | name: 'Manual Release'
205 |
206 | on:
207 | workflow_dispatch:
208 | inputs:
209 | title:
210 | type: string
211 | required: true
212 | description: Enter the release title
213 |
214 | jobs:
215 | call_build:
216 | uses: ./.github/workflows/ci.yaml
217 | with:
218 | artifact_name: apiapp
219 |
220 | call_release:
221 | uses: ./.github/worlfows/cd.yaml
222 | needs: call_build
223 | with:
224 | title: ${{ github.event.inputs.title }}
225 | artifact_name: apiapp
226 | secrets: inherit
227 | ```
228 |
229 |
230 | ### `ci.yaml` ###
231 |
232 | ```yaml
233 | name: 'Continuous Integration'
234 |
235 | on:
236 | workflow_call:
237 | inputs:
238 | artifact_name:
239 | type: string
240 | required: false
241 | description: Name of artifact
242 | default: apiapp
243 |
244 | jobs:
245 | build:
246 | name: Build Apps
247 |
248 | runs-on: ubuntu-latest
249 |
250 | steps:
251 | - name: Checkout the repo
252 | uses: actions/checkout@v2
253 |
254 | - name: Setup .NET SDK
255 | uses: actions/setup-dotnet@v1
256 | with:
257 | dotnet-version: '6.x'
258 |
259 | - name: Restore NuGet packages
260 | shell: bash
261 | run: |
262 | dotnet restore ./api
263 |
264 | - name: Build solution
265 | shell: bash
266 | run: |
267 | dotnet build ./api -c Release
268 |
269 | - name: Create FunctionApp artifact
270 | shell: bash
271 | run: |
272 | dotnet publish ./api -c Release -o ./api/bin/published
273 |
274 | - name: Upload FunctionApp artifact
275 | uses: actions/upload-artifact@v2
276 | with:
277 | name: ${{ inputs.artifact_name }}
278 | path: api/bin/published
279 | ```
280 |
281 |
282 | ### `cd.yaml` ###
283 |
284 | ```yaml
285 | name: 'Continuous Deployment'
286 |
287 | on:
288 | workflow_call:
289 | inputs:
290 | title:
291 | type: string
292 | required: true
293 | description: Enter the release title
294 | artifact_name:
295 | type: string
296 | required: false
297 | description: Name of artifact
298 | default: apiapp
299 |
300 | jobs:
301 | release:
302 | name: Release Apps
303 |
304 | runs-on: ubuntu-latest
305 |
306 | steps:
307 | - name: Download FunctionApp artifact
308 | uses: actions/download-artifact@v2
309 | with:
310 | name: ${{ inputs.artifact_name }}
311 | path: artifacts/api
312 |
313 | - name: Zip FunctionApp artifact
314 | shell: bash
315 | run: |
316 | pushd artifacts/api
317 | zip -qq -r ${{ inputs.artifact_name }}.zip .
318 | popd
319 |
320 | mv artifacts/api/${{ inputs.artifact_name }}.zip artifacts/${{ inputs.artifact_name }}.zip
321 |
322 | - name: Release FunctionApp artifact to GitHub
323 | uses: "marvinpinto/action-automatic-releases@latest"
324 | with:
325 | repo_token: "${{ secrets.GITHUB_TOKEN }}"
326 | prerelease: false
327 | title: ${{ inputs.title }}
328 | files: |
329 | artifacts/${{ inputs.artifact_name }}.zip
330 | ```
331 |
--------------------------------------------------------------------------------
/step-05.md:
--------------------------------------------------------------------------------
1 | # Multi-Stage Deployments #
2 |
3 | ## Release to DEV/PROD ##
4 |
5 | ### `main.yaml` ###
6 |
7 | ```yaml
8 | name: 'My First GitHub Actions'
9 |
10 | on:
11 | push:
12 | branches:
13 | - main
14 | tags:
15 | - 'v*'
16 | pull_request:
17 | branches:
18 | - main
19 |
20 | jobs:
21 | call_build:
22 | uses: ./.github/workflows/ci.yaml
23 | with:
24 | artifact_name: apiapp
25 |
26 | call_release_dev:
27 | uses: ./.github/worlfows/cd.yaml
28 | needs: call_build
29 | with:
30 | title: latest
31 | artifact_name: apiapp
32 | env: DEV
33 | secrets: inherit
34 |
35 | call_release_prod:
36 | uses: ./.github/worlfows/cd.yaml
37 | needs: call_release_dev
38 | with:
39 | title: latest
40 | artifact_name: apiapp
41 | env: PROD
42 | secrets: inherit
43 | ```
44 |
45 |
46 | ### `cd.yaml` ###
47 |
48 | ```yaml
49 | name: 'Continuous Deployment'
50 |
51 | on:
52 | workflow_call:
53 | inputs:
54 | title:
55 | type: string
56 | required: true
57 | description: Enter the release title
58 | artifact_name:
59 | type: string
60 | required: false
61 | description: Name of artifact
62 | default: apiapp
63 | env:
64 | type: string
65 | required: false
66 | description: Environment name
67 | default: DEV
68 |
69 | jobs:
70 | release:
71 | name: Release Apps
72 |
73 | runs-on: ubuntu-latest
74 |
75 | environment: ${{ inputs.env }}
76 |
77 | steps:
78 | - name: Download FunctionApp artifact
79 | uses: actions/download-artifact@v2
80 | with:
81 | name: ${{ inputs.artifact_name }}
82 | path: artifacts/api
83 |
84 | - name: Zip FunctionApp artifact
85 | shell: bash
86 | run: |
87 | pushd artifacts/api
88 | zip -qq -r ${{ inputs.artifact_name }}-${{ inputs.env }}.zip .
89 | popd
90 |
91 | mv artifacts/api/${{ inputs.artifact_name }}-${{ inputs.env }}.zip artifacts/${{ inputs.artifact_name }}-${{ inputs.env }}.zip
92 |
93 | - name: Release FunctionApp artifact to GitHub
94 | uses: "marvinpinto/action-automatic-releases@latest"
95 | with:
96 | repo_token: "${{ secrets.GITHUB_TOKEN }}"
97 | prerelease: false
98 | title: ${{ inputs.title }}
99 | files: |
100 | artifacts/${{ inputs.artifact_name }}-${{ inputs.env }}.zip
101 | ```
102 |
--------------------------------------------------------------------------------
/step-06.md:
--------------------------------------------------------------------------------
1 | # Docker-Based GitHub Action #
2 |
3 | TBD
4 |
--------------------------------------------------------------------------------
/step-07.md:
--------------------------------------------------------------------------------
1 | # JavaScript-Based GitHub Action #
2 |
3 | TBD
4 |
--------------------------------------------------------------------------------