Github_Actions/3. Variables _ Hands-on GitHub Actions_ Implement CI_CD with GitHub Action Workflows for Your Applications.html

27 lines
972 KiB
HTML
Raw Permalink Normal View History

2023-06-15 10:36:50 +02:00
<!DOCTYPE html> <html class="sevogelnj idc0_331" lang=en><!--
Page saved with SingleFile
url: https://learning.oreilly.com/library/view/hands-on-github-actions/9781484264645/html/502534_1_En_3_Chapter.xhtml
saved date: Tue Aug 03 2021 16:17:28 GMT+0200 (Central European Summer Time)
--><meta charset=utf-8>
<meta name=viewport content="width=device-width, initial-scale=1">
<meta name=theme-color content=#B9002D>
<meta data-react-helmet=true property=og:image content=https://learning.oreilly.com/covers/urn:orm:book:9781484264645/><meta data-react-helmet=true name=twitter:image content=https://learning.oreilly.com/covers/urn:orm:book:9781484264645/><meta data-react-helmet=true name=twitter:card content=summary><meta data-react-helmet=true name=twitter:creator content=@OReillyMedia><meta data-react-helmet=true name=twitter:site content=@OReillyMedia><meta data-react-helmet=true name=twitter:title content="O'Reilly Media - Technology and Business Training"><meta data-react-helmet=true property=twitter:account_id content=4503599627559754><meta data-react-helmet=true property=og:site_name content="O'Reilly Online Learning"><meta data-react-helmet=true name=publisher content=Apress><meta data-react-helmet=true property=og:book:author itemprop=author content="Chaminda Chandrasekara"><meta data-react-helmet=true property=og:book:author itemprop=author content="Pushpa Herath"><meta data-react-helmet=true property=og:type content=book><meta data-react-helmet=true property=og:book:isbn itemprop=isbn content=9781484264645>
<title>3.&nbsp;Variables | Hands-on GitHub Actions: Implement CI/CD with GitHub Action Workflows for Your Applications</title>
<style>@font-face{font-family:"ORM Icons";font-style:normal;font-weight:400;src:url(data:font/woff2;base64,d09GMgABAAAAAEggAAsAAAAApfAAAEfOAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHJxkBlYAlz4KgfRwgctMATYCJAOGNAuDHAAEIAWEIgeRVhvpjoeCcDuAUCH183Zm1EYtVuGzozFsHACUuW+y//+zkg4ZG+MO+PPqraqggJCoSEhCH7SEII8wtQ9UmbJCec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5A8/PnR04354byg0R7ynp98ZD7aT5jr+BiswMw/5F5AHg/TQEhE0CYAYjQAUkaIGUOSHsCMu6ArBkg5wzIuwAKtoCiK6BkDSj7AipegKo9oOYEqNsAGh6Aph2g5Q9oWwE6joCuJaDnAOh7AwZugKEPYGQBGNdvgwUMGShk4JBBGCKGimHiYIQQjBSS0UIxRmjGCsM4YRkvHBOEZ6IITBKRySIxRWSmisI0UZkuGjNEZ6YYzBKT2WIxR2zmisM8cZkvHgvEZ6EELJKQxRKxRGKWSsIySVkuGSskZ6UUrJKS1VKxRmrWScN6adkgHRulZ5MMbJaRrTKxTWa2y8IOWdkpG7tkZ7cc7JGTvXKxT2725+FAXg7m41B+DhfgSEGOFmKqwhwrwvGinCjGyeKcLsGZkpwtxbnSnC/DhbJcLMfl8lxZgasqcnUlrqnMtVW4vio3VOPG6txcg1tqcmstbqvN7XW4oy531uOu+tzdgHsbcn8jHmjMg03wUJM83BSPNs1jzfB4szzRHE81zzMt8FyLvNASL7bMS63wcqu80hqvts5r
<meta itemprop=isPartOf content=/library/view/hands-on-github-actions/9781484264645/ data-react-helmet=true><meta property=og:url itemprop=url content=https://learning.oreilly.com/library/view/hands-on-github-actions/9781484264645/html/502534_1_En_3_Chapter.xhtml data-react-helmet=true><meta name=search-title content=3.&nbsp;Variables data-react-helmet=true><meta property=og:title content=3.&nbsp;Variables data-react-helmet=true><meta itemprop=name content=3.&nbsp;Variables data-react-helmet=true><meta property=og:description itemprop=description content="©&nbsp;The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature&nbsp;2021C. Chandrasekara, P. HerathHands-on GitHub..." data-react-helmet=true><meta name=twitter:description content="©&nbsp;The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature&nbsp;2021C. Chandrasekara, P. HerathHands-on GitHub..." data-react-helmet=true><link rel="shortcut icon" href="data:image/vnd.microsoft.icon;base64,AAABAAMAEBAAAAEAIABoBAAANgAAACAgAAABACAAqBAAAJ4EAAAwMAAAAQAgAKglAABGFQA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0A1AAuANUBLgDVBi4A1AovANQGLgDVAS0A1AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALgDUAC8A1QIuANQlLQDTYy0A05gtANO2LQDTvy0A07ctANOZLQDTZS4A1CcvANUDLwDUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALQDTAC0A1AAuANQgLQDTiC0A098tANP9LQDT/y0A0/8tANP/LQDT/y0A0/8tANP9LQDT4S0A040uANQjKQDNADAA1wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC4A1AA4ANsALQDTQy0A080tANP+LQDT/y0A0/8tANP/LQDT/y0A0/8tANP/LQDT/y0A0/8tANP/LQDT/y0A09EtANRILwDXAS4A1AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAvANUAKwDRAC0A00ktANPhLQDT/y0A0/8tANP/LQDT/y0A0/8tANP7LQDT9i0A0/otANP/
<body>
<noscript class=sf-hidden>
<iframe src='https://www.googletagmanager.com/ns.html?id=GTM-5P4V6Z'
height='0' width='0' style='display:none;visibility:hidden'></iframe>
</noscript>
<div id=root><div class=orm-ff-Shell-shell__wrapper><a href=#main class=orm-ff-Shell-skipLink>Skip to content</a><header class="orm-ff-Shell-sidebar orm-ff-Shell-collapsedSidebar"><div class=orm-ff-Navigation-collapsed__wrapper><div class=orm-ff-Logo-LogoWrapper data-testid=collapsed-logo><a href=https://learning.oreilly.com/><svg width=40 height=40 viewBox="0 0 40 40" fill=none xmlns=http://www.w3.org/2000/svg><circle cx=20 cy=20 r=18 fill=#D3002D></circle><mask id=mask0 mask-type=alpha maskUnits=userSpaceOnUse x=10 y=11 width=24 height=18><path fill-rule=evenodd clip-rule=evenodd d="M19.8774 11C16.2373 10.9999 12.9556 13.1926 11.5626 16.5556C10.1696 19.9185 10.9396 23.7895 13.5136 26.3634C15.1978 28.0566 17.4892 29.0059 19.8774 29C23.5176 29.0002 26.7994 26.8075 28.1924 23.4444C29.5855 20.0813 28.8153 16.2102 26.2412 13.6364C24.5569 11.9432 22.2655 10.9939 19.8774 11ZM25.5315 20.0001C25.5303 22.6961 23.6251 25.0158 20.9809 25.541C18.3366 26.0662 15.6895 24.6506 14.6582 22.1598C13.6268 19.6689 14.4983 16.7964 16.7398 15.2986C18.9813 13.8007 21.9687 14.0946 23.8754 16.0005C24.9393 17.0591 25.5357 18.4993 25.5315 20.0001ZM28.6361 12.4394C28.9972 11.5679 29.8478 10.9998 30.7911 11C32.0782 11.0016 33.1212 12.0445 33.1227 13.3316C33.1229 14.275 32.5548 15.1255 31.6833 15.4867C30.8118 15.8478 29.8086 15.6483 29.1415 14.9812C28.4745 14.3142 28.275 13.3109 28.6361 12.4394Z" fill=white></path></mask><g mask=url(#mask0)><path fill-rule=evenodd clip-rule=evenodd d="M10 8H34V32H10V8Z" fill=white></path></g></svg></a></div><div class="orm-ff-LogoView-root orm-ff-Navigation-logoView orm-ff-LogoView-collapsedNav"><div class="orm-ff-LogoView-container orm-ff-LogoView-collapsedNav"><div class="orm-ff-LogoView-logoWrapper orm-ff-LogoView-collapsedNav" data-testid=nav-logo><a href=https://learning.oreilly.com/ class="orm-Logo-logoWrapper orm-ff-LogoView-ormLogoWrapper orm-ff-LogoView-collapsedLogo"><span class="orm-Logo-root orm-ff-LogoView-ormLogoRoot orm-ff-LogoView-collapsedLogo orm-Logo-small">
<svg width=148 height=26 viewBox="0 0 148 26" xmlns=http://www.w3.org/2000/svg>
<g fill=#FFF fill-rule=evenodd>
<path d="M70.46 5.45V1.641H54.516v22.864h15.946v-3.812H58.337v-5.71h11.54v-3.81h-11.54V5.45h12.124M82.291 24.502V1.642h3.825v19.05h11.032v3.81H82.29M100.262 24.502V1.642h3.822v19.05h11.031v3.81h-14.853M74.475 24.502h3.818V1.638h-3.818zM6.773 7.446a8.09 8.09 0 0 0-2.38 5.73c0 2.242.91 4.25 2.38 5.723a8.085 8.085 0 0 0 5.745 2.379 8.074 8.074 0 0 0 5.746-2.38 8.036 8.036 0 0 0 2.377-5.723 8.074 8.074 0 0 0-2.377-5.73 8.114 8.114 0 0 0-5.746-2.362c-2.25 0-4.265.9-5.745 2.363M.57 13.176c0-6.579 5.347-11.902 11.947-11.909 6.6.007 11.948 5.33 11.948 11.909 0 6.577-5.348 11.908-11.948 11.908-6.6 0-11.947-5.33-11.947-11.909M36.284 11.17V5.45h7.705a2.868 2.868 0 0 1 2.866 2.86 2.875 2.875 0 0 1-2.866 2.86h-7.705zm9.62 3.527c2.761-.83 4.77-3.367 4.776-6.387a6.686 6.686 0 0 0-6.69-6.669H32.458v22.86h3.825v-9.519h5.331l5.762 9.52h4.461l-5.935-9.805zM29.752 4.075a2.81 2.81 0 0 1-2.814 2.805 2.808 2.808 0 0 1-2.814-2.804 2.81 2.81 0 0 1 2.814-2.808 2.813 2.813 0 0 1 2.814 2.808M132.163 1.641h-4.647l-5.886 8.49-5.885-8.49h-4.647l8.615 12.438v10.426h3.825V14.089l8.625-12.448M141.675 11.612c-2.791 0-5.048-2.255-5.048-5.027a5.043 5.043 0 0 1 5.048-5.041 5.049 5.049 0 0 1 5.045 5.04c0 2.773-2.267 5.028-5.045 5.028m0-11.017c-3.313 0-6.01 2.675-6.01 5.99 0 3.298 2.697 5.983 6.01 5.983 3.316 0 6.003-2.685 6.003-5.983a5.992 5.992 0 0 0-6.003-5.99"></path>
<path d="M140.224 4.498h2.364c.424 0 .76.345.763.77a.76.76 0 0 1-.763.754h-2.364V4.498zm4.148.77c0-.994-.8-1.79-1.784-1.79H139.2v6.11h1.024V7.049h1.709l1.229 2.538h1.138l-1.262-2.6a1.77 1.77 0 0 0 1.334-1.719z"></path>
</g>
</svg></span><span class=orm-Logo-logoTitle>O'Reilly</span></a></div></div></div><div class=orm-ff-Navigation-primaryNav__wrapper><div class=orm-ff-NavigationView-root><div class="orm-ff-NavigationView-container orm-ff-NavigationView-collapsedNav"><div class=orm-ff-NavigationView-headerMenu><div class=orm-ff-NavigationView-headerControls><nav aria-label=Primary><ul class=orm-ff-NavigationView-headerList data-testid=primaryHeaderMenuItems><li class=orm-ff-NavigationView-headerListItem><a href=https://learning.oreilly.com/home/ class="orm-Link-root orm-Link-hasIcon"><span class="orm-Icon-root orm-Link-icon orm-ff-NavigationView-linkIcon" aria-hidden=true style=height:1rem data-testid=icon><span style=font-size:1rem;width:1rem;height:1rem class="orm-Icon-icon orm-icon-home" aria-hidden=true></span><span class=orm-Icon-title>home</span></span>Home</a><li class=orm-ff-NavigationView-toggleControls><button aria-expanded=false class="orm-Button-root orm-ToggleLinks-root orm-Button-small"><span class="orm-Button-btnContentWrap orm-ToggleLinks-btnContentWrap"><span class=orm-ToggleLinks-iconContentWrap><span class="orm-Icon-root orm-ToggleLinks-extraIcon orm-ToggleLinks-showHideIcon" aria-hidden=true style=height:1rem data-testid=icon><span style=font-size:1rem;width:1rem;height:1rem class="orm-Icon-icon orm-icon-person" aria-hidden=true></span><span class=orm-Icon-title>person</span></span>Your O'Reilly</span><span class=orm-Icon-root aria-hidden=true style=height:1rem data-testid=icon><span style=font-size:1rem;width:1rem;height:1rem class="orm-Icon-icon orm-Button-icon orm-ToggleLinks-toggleIcon orm-icon-chevron-down" aria-hidden=true></span><span class=orm-Icon-title>chevron down</span></span></span></button><ul class=orm-ToggleLinks-toggleList><li class=orm-ff-NavigationView-toggleListItem><a href=https://learning.oreilly.com/profile/ class=orm-Link-root><span class=orm-ff-NavigationView-toggleListLabel>Profile</span></a><li class=orm-ff-NavigationView-toggleListItem><a href=https://learning.oreilly.com/history/ class=orm-Link-root><span class=orm-ff-NavigationView-toggleListLabel>History</span></a><li class=orm-ff-NavigationView-toggleListItem><a href=https://learning.oreilly.com/playlists/ class=orm-Link-root><span class=orm-ff-NavigationView-toggleListLabel>Playlists</span></a><li class=orm-ff-NavigationView-toggleListItem><a href=https://learning.oreilly.com/u/df548b90-632b-4f02-aeed-c8a0e13a6eb7/ class=orm-Link-root><span class=orm-ff-NavigationView-toggleListLabel>Highlights</span></a></ul><li class=orm-ff-NavigationView-headerListItem><a href=https://learning.oreilly.com/answers/ class="orm-Link-root orm-Link-hasIcon"><span class="orm-Icon-root orm-Link-icon orm-ff-NavigationView-linkIcon" aria-hidden=true style=height:1rem data-testid=icon><span style=font-size:1rem;width:1rem;height:1rem class="orm-Icon-icon orm-icon-answers" aria-hidden=true></span><span class=orm-Icon-title>answers</span></span>Answers</a><li class=orm-ff-NavigationView-toggleControls><button aria-expanded=false class="orm-Button-root orm-ToggleLinks-root orm-Button-small"><span class="orm-Button-btnContentWrap orm-ToggleLinks-btnContentWrap"><span class=orm-ToggleLinks-iconContentWrap><span class="orm-Icon-root orm-ToggleLinks-extraIcon orm-ToggleLinks-showHideIcon" aria-hidden=true style=height:1rem data-testid=icon><span style=font-size:1rem;width:1rem;height:1rem class="orm-Icon-icon orm-icon-queue" aria-hidden=true></span><span class=orm-Icon-title>queue</span></span>Explore</span><span class=orm-Icon-root aria-hidden=true style=height:1rem data-testid=icon><span style=font-size:1rem;width:1rem;height:1rem class="orm-Icon-icon orm-Button-icon orm-ToggleLinks-toggleIcon orm-icon-chevron-down" aria-hidden=true></span><span class=orm-Icon-title>chevron down</span></span></span></button><ul class=orm-ToggleLinks-toggleList><li class=orm-ff-NavigationView-toggleListItem><a href=https://learning.oreilly.com/topics/ class=orm-Link-root><span class=orm-ff-NavigationView-toggleListLabel>All Topics</span></a><li class=orm-ff-NavigationView-toggleListI
</span> lets you create a new variable or change an existing variable's value. However, the variable created or value changed is not visible in the current action or the step. It is only available in subsequent steps or actions in the job. To set the value of a variable or create a new variable, you can use the following syntax.<div class=ProgramCode id=PC8><div class=LineGroup><div class=FixedLine>echo "::set-env name=varname::varvalue"</div></div></div></div><div class=Para id=Par12>You can set the variable <span class=EmphasisFontCategoryNonProportional>user_name</span> value to a different value, as shown in the following example.<div class=ProgramCode id=PC9><div class=LineGroup><div class=FixedLine>echo "::set-env name=user_name::Chandrasekara"</div></div></div></div><div class=Para id=Par13>The following example of a full workflow can be used for further reference.<div class=ProgramCode id=PC10><div class=LineGroup><div class=FixedLine>name: VariableDemo</div></div><div class=LineGroup><div class=FixedLine>on: [push]</div><div class=FixedLine>env:</div><div class=FixedLine>&nbsp;user_name: "Chaminda"</div><div class=FixedLine>&nbsp;demo_name: "Variable Demo"</div></div><div class=LineGroup><div class=FixedLine>jobs:</div><div class=FixedLine>&nbsp;VariableUsageJob:</div><div class=FixedLine>&nbsp;&nbsp;runs-on: ubuntu-latest</div><div class=FixedLine>&nbsp;&nbsp;env:</div><div class=FixedLine>&nbsp;&nbsp;&nbsp;job_var1: "job variable value"</div><div class=FixedLine>&nbsp;&nbsp;steps:</div><div class=FixedLine>&nbsp;&nbsp;- name: Using Workflow Variables</div><div class=FixedLine>&nbsp;&nbsp;&nbsp;&nbsp;run: echo Hello, $user_name!</div><div class=FixedLine>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Welcome to $demo_name!!!</div><div class=FixedLine>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;here is job var1 $job_var1</div><div class=FixedLine>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;here is step var1 $step_var1</div><div class=FixedLine>&nbsp;&nbsp;&nbsp;&nbsp;env:</div><div class=FixedLine>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;step_var1: "Step Variable Value"</div></div><div class=LineGroup><div class=FixedLine>&nbsp;&nbsp;- name: Set user_name Varaible</div><div class=FixedLine>&nbsp;&nbsp;&nbsp;&nbsp;run: echo "::set-env name=user_name::Chandrasekara"</div></div><div class=LineGroup><div class=FixedLine>&nbsp;&nbsp;- name: Set new_var Varaible</div><div class=FixedLine>&nbsp;&nbsp;&nbsp;&nbsp;run: echo "::set-env name=new_var::newvarvalue"</div></div><div class=LineGroup><div class=FixedLine>&nbsp;&nbsp;- name: Using Variables</div><div class=FixedLine>&nbsp;&nbsp;&nbsp;&nbsp;run: echo Hello, $user_name!</div><div class=FixedLine>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Welcome to $demo_name!!!</div><div class=FixedLine>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;here is job var1 $job_var1</div><div class=FixedLine>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;here is new_var $new_var</div></div></div></div><p class=Para id=Par14>This section identified the options to define custom environment variables in a GitHub Actions workflow with syntax references. It explained how to use the variables in the workflow steps or actions. Additionally, it looked at how to change a variable value or create a variable via an action using the <span class=EmphasisFontCategoryNonProportional>set-env</span> command.</p></section></section><section class="Section1 RenderAsSection1" id=Sec6><h2 class=Heading>Default Variables</h2><div class=Para id=Par15>A GitHub Actions workflow has a set of <span id=ITerm6>default variables</span>.<div class=UnorderedList><ul class=UnorderedListMarkBullet><li><p class=Para id=Par16><strong class=EmphasisTypeBold>CI</strong>: This variable value is always set to true.</p><li><p class=Para id=Par17><strong class=EmphasisTypeBold>HOME</strong>: The home directory in the runner storing user data in the workflow.</p><li><p class=Para id=Par18><strong class=EmphasisTypeBold>GITHUB_WORKFLOW</strong>: GitHub workflow name.</p><li><p class=
</span><section class="Section2 RenderAsSection2" id=Sec8><h3 class=Heading>GITHUB_ Prefix</h3><p class=Para id=Par39>The GITHUB_ prefix is reserved for GitHub. You cannot use it in naming custom environment variables. If you try to use <span id=ITerm8>GITHUB</span>_, it results in an error in the workflow.</p></section><section class="Section2 RenderAsSection2" id=Sec9><h3 class=Heading>Case Sensitivity</h3><p class=Para id=Par40>GitHub variables are case <span id=ITerm9>sensitive</span>. Hence, a variable name and its usage should use the same case, or else the variable value cannot be retrieved in the usage location of the workflow.</p></section><section class="Section2 RenderAsSection2" id=Sec10><h3 class=Heading>_PATH Suffix</h3><p class=Para id=Par41>The variables you define to point to a filesystem location should contain the <span id=ITerm10>_PATH suffix</span>. However, the HOME and GITHUB_WORKSPACE default variables do not use this convention because the words <em class=EmphasisTypeItalic>home</em> and <em class=EmphasisTypeItalic>workspace</em> imply a location.</p></section><section class="Section2 RenderAsSection2" id=Sec11><h3 class=Heading>Special Characters</h3><p class=Para id=Par42>Even though there are no syntactical errors caused by using <span id=ITerm11>special characters</span> in the middle of a variable name, it is better to avoid them at all costs because such variables cannot be properly retrieved when used in workflow steps/actions. Using an underscore (_) to separate parts of a variable name is acceptable. Variable names must begin with an alphabetical character and may contain numbers in the middle or at the end of the name. However, the variable name should not begin with a number. Special characters other than _ should be avoided.<div class=Para id=Par43>For example, valid variables to use are only <span class=EmphasisFontCategoryNonProportional>user_name</span>, <span class=EmphasisFontCategoryNonProportional>demo_name</span>, and <span class=EmphasisFontCategoryNonProportional>my1_var1</span>, out of the all the variables below, even though none of them is giving any syntax errors.<div class=ProgramCode id=PC13><div class=LineGroup><div class=FixedLine>name: VariableDemo</div></div><div class=LineGroup><div class=FixedLine>on: [push]</div><div class=FixedLine>env:</div><div class=FixedLine>&nbsp;user_name: "Chaminda"</div><div class=FixedLine>&nbsp;demo_name: "Variable Demo"</div><div class=FixedLine>&nbsp;my@newvar@$: "specialvarval"</div><div class=FixedLine>&nbsp;$varwith$: "valwith$"</div><div class=FixedLine>&nbsp;1mynewnumvar: "numvarval"</div><div class=FixedLine>&nbsp;my-var: "DashVarvalue"</div><div class=FixedLine>&nbsp;my1_var1: "my1_var1value"</div></div></div></div><p class=Para id=Par44>In this section we have looked at considerations in creating custom variables in GitHub Actions workflows.</p></section></section><section class="Section1 RenderAsSection1" id=Sec12><h2 class=Heading>Summary</h2><p class=Para id=Par45>This chapter discussed using custom environment variables and the default variables available in GitHub Actions workflows and used a .NET Core example. It also discussed naming conventions for variables.<p class=Para id=Par46>The next chapter explores the use of secrets and tokens in GitHub Actions workflows.</p></section></div></div></div></div><style>#book-content #sbo-rt-content div,#book-content #sbo-rt-content ul,#book-content #sbo-rt-content h2,#book-content #sbo-rt-content h3,#book-content #sbo-rt-content p{margin:0;padding:0;-webkit-margin-before:0;-webkit-margin-after:0}#book-content #sbo-rt-content div{background-color:inherit}#book-content #sbo-rt-content strong{font-style:normal}#book-content #sbo-rt-content strong{font-weight:bold}#book-content #sbo-rt-content em{font-style:italic}.ucvMode-black #book-content #sbo-rt-content h1,.ucvMode-black #book-content #sbo-rt-content h2,.ucvMode-black #book-content #sbo-rt-content h3{color:#fff!important}#book-content #sbo-rt-content section{display:block;border:none;margin:0;padding:0}html{font-size:100%!imp