├── .github ├── ISSUE_TEMPLATE │ └── bug-report---feature-request.md ├── config │ └── labels.yml └── workflows │ ├── add-labels.yml │ ├── build-release.yml │ ├── ci-workflow.yml │ ├── defaultLabel.yml │ ├── integration-test.yml │ ├── pr-test.yml │ └── stale.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── HowToBuild.md ├── LICENSE ├── README.md ├── ReleaseProcess.md ├── SECURITY.md ├── _config.yml ├── action.yml ├── dist └── index.js ├── package-lock.json ├── package.json ├── src ├── entrypoint.ts ├── main.ts └── utils.ts ├── test └── main.test.ts └── tsconfig.json /.github/ISSUE_TEMPLATE/bug-report---feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report / Feature Request 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: need-to-triage 6 | assignees: MoChilia 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/config/labels.yml: -------------------------------------------------------------------------------- 1 | - name: need-to-triage 2 | color: "#fbca04" 3 | description: "Requires investigation" 4 | 5 | - name: idle 6 | color: "#9A777A" 7 | description: "Inactive for 14 days" 8 | 9 | - name: stale 10 | color: "#A9A9A9" 11 | description: "90 days old" 12 | 13 | - name: question 14 | color: "#d876e3" 15 | description: "Requiring some clarification" 16 | 17 | - name: bug 18 | color: "#d73a4a" 19 | description: "Something is not working" 20 | 21 | - name: P0 22 | color: "#B60205" 23 | description: "Action not working" 24 | 25 | - name: P1 26 | color: "#EE3D1D" 27 | description: "Some scenario broken but workaround exists" 28 | 29 | - name: enhancement 30 | color: "#a2eeef" 31 | description: "Feature request/improved experience" 32 | 33 | - name: documentation 34 | color: "#0075ca" 35 | description: "Improvements or additions to documentation" 36 | 37 | - name: backlog 38 | color: "#bd7e4b" 39 | description: "Planned for future" 40 | 41 | - name: performance-issue 42 | color: "#0e8a16" 43 | description: "Performance improvement required" 44 | 45 | - name: waiting-for-customer 46 | color: "#0e8a16" 47 | description: "Waiting for inputs from customer" 48 | -------------------------------------------------------------------------------- /.github/workflows/add-labels.yml: -------------------------------------------------------------------------------- 1 | name: add-labels 2 | on: 3 | workflow_dispatch: 4 | 5 | jobs: 6 | test_action_job: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Check out source code 10 | uses: actions/checkout@v4 11 | - name: Synchronize labels 12 | uses: julb/action-manage-label@v1 13 | with: 14 | from: .github/config/labels.yml 15 | skip_delete: true 16 | env: 17 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 18 | -------------------------------------------------------------------------------- /.github/workflows/build-release.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | 6 | name: build-release 7 | 8 | permissions: 9 | contents: write 10 | 11 | jobs: 12 | build: 13 | name: build-release 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout Code 17 | uses: actions/checkout@v4 18 | 19 | - name: Setup Node.js 20 | uses: actions/setup-node@v4 21 | with: 22 | node-version: "20.x" 23 | 24 | - run: sudo npm i -g @vercel/ncc 25 | 26 | - run: npm install 27 | 28 | - name: Compile files 29 | run: | 30 | ncc build -C -m src/entrypoint.ts 31 | 32 | - name: Commit Files 33 | continue-on-error: true # commit will fail if the code wasn't changed. Prevent the build to fail in this case. 34 | run: | 35 | git config --local user.email "action@github.com" 36 | git config --local user.name "GitHub Action" 37 | 38 | git add dist/index.js -f 39 | git commit -m "Add changes" 40 | 41 | - name: Push changes 42 | uses: ad-m/github-push-action@master 43 | with: 44 | github_token: ${{ secrets.GITHUB_TOKEN }} 45 | branch: master 46 | -------------------------------------------------------------------------------- /.github/workflows/ci-workflow.yml: -------------------------------------------------------------------------------- 1 | name: ci-workflow 2 | on: 3 | push: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | test_action_job: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Check out source code 11 | uses: actions/checkout@v4 12 | 13 | - uses: azure/login@v2 14 | with: 15 | creds: ${{ secrets.AZURE_CREDENTIALS }} 16 | 17 | - name: Setup Node.js 18 | uses: actions/setup-node@v4 19 | with: 20 | node-version: "20.x" 21 | 22 | - run: npm install --production 23 | 24 | - run: npm i -g ts-node 25 | - run: npm install typescript 26 | 27 | - name: Azure CLI Version test 28 | env: 29 | INPUT_AZCLIVERSION: 2.0.72 30 | INPUT_INLINESCRIPT: | 31 | az account show 32 | az storage -h 33 | EXPECTED_TO: pass 34 | run: ts-node test/main.test.ts 35 | 36 | - name: Azure CLI Version Test - Negative 37 | env: 38 | INPUT_AZCLIVERSION: 0 39 | INPUT_INLINESCRIPT: | 40 | az account show 41 | az storage -h 42 | EXPECTED_TO: fail 43 | run: ts-node test/main.test.ts 44 | 45 | - name: Inline Script Test - Negative 46 | env: 47 | INPUT_AZCLIVERSION: 2.0.72 48 | INPUT_INLINESCRIPT: " " 49 | EXPECTED_TO: fail 50 | run: ts-node test/main.test.ts 51 | -------------------------------------------------------------------------------- /.github/workflows/defaultLabel.yml: -------------------------------------------------------------------------------- 1 | name: setting-default-labels 2 | 3 | # Controls when the action will run. 4 | on: 5 | schedule: 6 | - cron: "0 0/3 * * *" 7 | 8 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 9 | jobs: 10 | build: 11 | # The type of runner that the job will run on 12 | runs-on: ubuntu-latest 13 | 14 | # Steps represent a sequence of tasks that will be executed as part of the job 15 | steps: 16 | 17 | - uses: actions/stale@v3 18 | name: Setting issue as idle 19 | with: 20 | repo-token: ${{ secrets.GITHUB_TOKEN }} 21 | stale-issue-message: 'This issue is idle because it has been open for 14 days with no activity.' 22 | stale-issue-label: 'idle' 23 | days-before-stale: 7 24 | days-before-close: -1 25 | operations-per-run: 100 26 | exempt-issue-labels: 'backlog' 27 | 28 | - uses: actions/stale@v3 29 | name: Setting PR as idle 30 | with: 31 | repo-token: ${{ secrets.GITHUB_TOKEN }} 32 | stale-pr-message: 'This PR is idle because it has been open for 14 days with no activity.' 33 | stale-pr-label: 'idle' 34 | days-before-stale: 5 35 | days-before-close: -1 36 | operations-per-run: 100 37 | -------------------------------------------------------------------------------- /.github/workflows/integration-test.yml: -------------------------------------------------------------------------------- 1 | name: integration-test 2 | on: 3 | workflow_dispatch: 4 | schedule: 5 | - cron: '0 */3 * * *' 6 | 7 | jobs: 8 | basic_test: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: azure/login@v2 12 | with: 13 | creds: ${{ secrets.AZURE_CREDENTIALS }} 14 | 15 | - name: Specific test - Postive 16 | uses: azure/cli@master 17 | with: 18 | azcliversion: 2.30.0 19 | inlineScript: | 20 | az --version 21 | az account show --output none 22 | 23 | - name: Latest version test - Postive 24 | uses: azure/cli@master 25 | with: 26 | azcliversion: latest 27 | inlineScript: | 28 | az --version 29 | az account show --output none 30 | 31 | - name: Default version test - Postive 32 | uses: azure/cli@master 33 | with: 34 | inlineScript: | 35 | az --version 36 | az account show --output none 37 | 38 | - name: Invalid Version test - Negative 39 | id: test1 40 | continue-on-error: true 41 | uses: azure/cli@master 42 | with: 43 | azcliversion: 0 44 | inlineScript: | 45 | az --version 46 | 47 | - name: Check Last step failed 48 | if: steps.test1.outcome == 'success' 49 | uses: actions/github-script@v3 50 | with: 51 | script: | 52 | core.setFailed('Last action should fail but not. Please check it.') 53 | 54 | - name: Invalid Script test - Negative 55 | id: test2 56 | continue-on-error: true 57 | uses: azure/cli@master 58 | with: 59 | azcliversion: latest 60 | inlineScript: " " 61 | 62 | - name: Check Last step failed 63 | if: steps.test2.outcome == 'success' 64 | uses: actions/github-script@v3 65 | with: 66 | script: | 67 | core.setFailed('Last action should fail but not. Please check it.') 68 | 69 | os_test: 70 | runs-on: windows-latest 71 | steps: 72 | - uses: azure/login@v2 73 | with: 74 | creds: ${{ secrets.AZURE_CREDENTIALS }} 75 | 76 | - name: Invalid OS - Negative 77 | id: test3 78 | continue-on-error: true 79 | uses: azure/cli@master 80 | with: 81 | azcliversion: latest 82 | inlineScript: | 83 | az --version 84 | 85 | - name: Check Last step failed 86 | if: steps.test3.outcome == 'success' 87 | uses: actions/github-script@v3 88 | with: 89 | script: | 90 | core.setFailed('Last action should fail but not. Please check it.') 91 | -------------------------------------------------------------------------------- /.github/workflows/pr-test.yml: -------------------------------------------------------------------------------- 1 | name: pr-test 2 | on: 3 | pull_request: 4 | branches: 5 | - master 6 | - releases/* 7 | push: 8 | workflow_dispatch: 9 | 10 | jobs: 11 | basic_test: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Check out source code 15 | uses: actions/checkout@v4 16 | 17 | - name: Setup Node.js 18 | uses: actions/setup-node@v4 19 | with: 20 | node-version: "20.x" 21 | 22 | - name: Install dependencies 23 | run: | 24 | npm i -g @vercel/ncc 25 | npm install 26 | 27 | - name: Compile files 28 | run: | 29 | ncc build -C -m src/entrypoint.ts 30 | 31 | - name: Specific version test- Postive 32 | uses: ./ 33 | with: 34 | azcliversion: 2.30.0 35 | inlineScript: | 36 | az --version 37 | 38 | - name: Latest version test - Postive 39 | uses: ./ 40 | with: 41 | azcliversion: latest 42 | inlineScript: | 43 | az --version 44 | 45 | - name: Default version test - Postive 46 | uses: ./ 47 | with: 48 | inlineScript: | 49 | az --version 50 | 51 | - name: Invalid Version test - Negative 52 | id: test1 53 | continue-on-error: true 54 | uses: ./ 55 | with: 56 | azcliversion: 0 57 | inlineScript: | 58 | az --version 59 | 60 | - name: Check Last step failed 61 | if: steps.test1.outcome == 'success' 62 | uses: actions/github-script@v3 63 | with: 64 | script: | 65 | core.setFailed('Last action should fail but not. Please check it.') 66 | 67 | - name: Invalid Script test - Negative 68 | id: test2 69 | continue-on-error: true 70 | uses: ./ 71 | with: 72 | azcliversion: latest 73 | inlineScript: " " 74 | 75 | - name: Check Last step failed 76 | if: steps.test2.outcome == 'success' 77 | uses: actions/github-script@v3 78 | with: 79 | script: | 80 | core.setFailed('Last action should fail but not. Please check it.') 81 | 82 | os_test: 83 | runs-on: windows-latest 84 | steps: 85 | - name: Check out source code 86 | uses: actions/checkout@v4 87 | 88 | - name: Setup Node.js 89 | uses: actions/setup-node@v4 90 | with: 91 | node-version: "20.x" 92 | 93 | - name: Install dependencies 94 | run: | 95 | npm i -g @vercel/ncc 96 | npm install 97 | 98 | - name: Compile files 99 | run: | 100 | ncc build -C -m src/entrypoint.ts 101 | 102 | - name: Invalid OS - Negative 103 | id: test3 104 | continue-on-error: true 105 | uses: ./ 106 | with: 107 | azcliversion: latest 108 | inlineScript: | 109 | az --version 110 | 111 | - name: Check Last step failed 112 | if: steps.test3.outcome == 'success' 113 | uses: actions/github-script@v3 114 | with: 115 | script: | 116 | core.setFailed('Last action should fail but not. Please check it.') 117 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Mark stale issues 2 | 3 | on: 4 | schedule: 5 | - cron: "0 0/3 * * *" 6 | 7 | jobs: 8 | stale: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/stale@v3 13 | with: 14 | repo-token: ${{ secrets.GITHUB_TOKEN }} 15 | stale-issue-message: "This issue is stale because it has been open for 7 days with no activity." 16 | stale-issue-label: "stale" 17 | days-before-stale: 7 18 | days-before-close: -1 19 | operations-per-run: 100 20 | exempt-issue-labels: "backlog" 21 | -------------------------------------------------------------------------------- /.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 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015/2017 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # Visual Studio 2017 auto generated files 33 | Generated\ Files/ 34 | 35 | # MSTest test Results 36 | [Tt]est[Rr]esult*/ 37 | [Bb]uild[Ll]og.* 38 | 39 | # NUNIT 40 | *.VisualState.xml 41 | TestResult.xml 42 | 43 | # Build Results of an ATL Project 44 | [Dd]ebugPS/ 45 | [Rr]eleasePS/ 46 | dlldata.c 47 | 48 | # Benchmark Results 49 | BenchmarkDotNet.Artifacts/ 50 | 51 | # .NET Core 52 | project.lock.json 53 | project.fragment.lock.json 54 | artifacts/ 55 | **/Properties/launchSettings.json 56 | 57 | # StyleCop 58 | StyleCopReport.xml 59 | 60 | # Files built by Visual Studio 61 | *_i.c 62 | *_p.c 63 | *_i.h 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.iobj 68 | *.pch 69 | *.pdb 70 | *.ipdb 71 | *.pgc 72 | *.pgd 73 | *.rsp 74 | *.sbr 75 | *.tlb 76 | *.tli 77 | *.tlh 78 | *.tmp 79 | *.tmp_proj 80 | *.log 81 | *.vspscc 82 | *.vssscc 83 | .builds 84 | *.pidb 85 | *.svclog 86 | *.scc 87 | 88 | # Chutzpah Test files 89 | _Chutzpah* 90 | 91 | # Visual C++ cache files 92 | ipch/ 93 | *.aps 94 | *.ncb 95 | *.opendb 96 | *.opensdf 97 | *.sdf 98 | *.cachefile 99 | *.VC.db 100 | *.VC.VC.opendb 101 | 102 | # Visual Studio profiler 103 | *.psess 104 | *.vsp 105 | *.vspx 106 | *.sap 107 | 108 | # Visual Studio Trace Files 109 | *.e2e 110 | 111 | # TFS 2012 Local Workspace 112 | $tf/ 113 | 114 | # Guidance Automation Toolkit 115 | *.gpState 116 | 117 | # ReSharper is a .NET coding add-in 118 | _ReSharper*/ 119 | *.[Rr]e[Ss]harper 120 | *.DotSettings.user 121 | 122 | # JustCode is a .NET coding add-in 123 | .JustCode 124 | 125 | # TeamCity is a build add-in 126 | _TeamCity* 127 | 128 | # DotCover is a Code Coverage Tool 129 | *.dotCover 130 | 131 | # AxoCover is a Code Coverage Tool 132 | .axoCover/* 133 | !.axoCover/settings.json 134 | 135 | # Visual Studio code coverage results 136 | *.coverage 137 | *.coveragexml 138 | 139 | # NCrunch 140 | _NCrunch_* 141 | .*crunch*.local.xml 142 | nCrunchTemp_* 143 | 144 | # MightyMoose 145 | *.mm.* 146 | AutoTest.Net/ 147 | 148 | # Web workbench (sass) 149 | .sass-cache/ 150 | 151 | # Installshield output folder 152 | [Ee]xpress/ 153 | 154 | # DocProject is a documentation generator add-in 155 | DocProject/buildhelp/ 156 | DocProject/Help/*.HxT 157 | DocProject/Help/*.HxC 158 | DocProject/Help/*.hhc 159 | DocProject/Help/*.hhk 160 | DocProject/Help/*.hhp 161 | DocProject/Help/Html2 162 | DocProject/Help/html 163 | 164 | # Click-Once directory 165 | publish/ 166 | 167 | # Publish Web Output 168 | *.[Pp]ublish.xml 169 | *.azurePubxml 170 | # Note: Comment the next line if you want to checkin your web deploy settings, 171 | # but database connection strings (with potential passwords) will be unencrypted 172 | *.pubxml 173 | *.publishproj 174 | 175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 176 | # checkin your Azure Web App publish settings, but sensitive information contained 177 | # in these scripts will be unencrypted 178 | PublishScripts/ 179 | 180 | # NuGet Packages 181 | *.nupkg 182 | # The packages folder can be ignored because of Package Restore 183 | **/[Pp]ackages/* 184 | # except build/, which is used as an MSBuild target. 185 | !**/[Pp]ackages/build/ 186 | # Uncomment if necessary however generally it will be regenerated when needed 187 | #!**/[Pp]ackages/repositories.config 188 | # NuGet v3's project.json files produces more ignorable files 189 | *.nuget.props 190 | *.nuget.targets 191 | 192 | # Microsoft Azure Build Output 193 | csx/ 194 | *.build.csdef 195 | 196 | # Microsoft Azure Emulator 197 | ecf/ 198 | rcf/ 199 | 200 | # Windows Store app package directories and files 201 | AppPackages/ 202 | BundleArtifacts/ 203 | Package.StoreAssociation.xml 204 | _pkginfo.txt 205 | *.appx 206 | 207 | # Visual Studio cache files 208 | # files ending in .cache can be ignored 209 | *.[Cc]ache 210 | # but keep track of directories ending in .cache 211 | !*.[Cc]ache/ 212 | 213 | # Others 214 | ClientBin/ 215 | ~$* 216 | *~ 217 | *.dbmdl 218 | *.dbproj.schemaview 219 | *.jfm 220 | *.pfx 221 | *.publishsettings 222 | orleans.codegen.cs 223 | 224 | # Including strong name files can present a security risk 225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 226 | #*.snk 227 | 228 | # Since there are multiple workflows, uncomment next line to ignore bower_components 229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 230 | #bower_components/ 231 | 232 | # RIA/Silverlight projects 233 | Generated_Code/ 234 | 235 | # Backup & report files from converting an old project file 236 | # to a newer Visual Studio version. Backup files are not needed, 237 | # because we have git ;-) 238 | _UpgradeReport_Files/ 239 | Backup*/ 240 | UpgradeLog*.XML 241 | UpgradeLog*.htm 242 | ServiceFabricBackup/ 243 | *.rptproj.bak 244 | 245 | # SQL Server files 246 | *.mdf 247 | *.ldf 248 | *.ndf 249 | 250 | # Business Intelligence projects 251 | *.rdl.data 252 | *.bim.layout 253 | *.bim_*.settings 254 | *.rptproj.rsuser 255 | 256 | # Microsoft Fakes 257 | FakesAssemblies/ 258 | 259 | # GhostDoc plugin setting file 260 | *.GhostDoc.xml 261 | 262 | # Node.js Tools for Visual Studio 263 | .ntvs_analysis.dat 264 | node_modules/ 265 | 266 | # Visual Studio 6 build log 267 | *.plg 268 | 269 | # Visual Studio 6 workspace options file 270 | *.opt 271 | 272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 273 | *.vbw 274 | 275 | # Visual Studio LightSwitch build output 276 | **/*.HTMLClient/GeneratedArtifacts 277 | **/*.DesktopClient/GeneratedArtifacts 278 | **/*.DesktopClient/ModelManifest.xml 279 | **/*.Server/GeneratedArtifacts 280 | **/*.Server/ModelManifest.xml 281 | _Pvt_Extensions 282 | 283 | # Paket dependency manager 284 | .paket/paket.exe 285 | paket-files/ 286 | 287 | # FAKE - F# Make 288 | .fake/ 289 | 290 | # JetBrains Rider 291 | .idea/ 292 | *.sln.iml 293 | 294 | # CodeRush 295 | .cr/ 296 | 297 | # Python Tools for Visual Studio (PTVS) 298 | __pycache__/ 299 | *.pyc 300 | 301 | # Cake - Uncomment if you are using it 302 | # tools/** 303 | # !tools/packages.config 304 | 305 | # Tabs Studio 306 | *.tss 307 | 308 | # Telerik's JustMock configuration file 309 | *.jmconfig 310 | 311 | # BizTalk build output 312 | *.btp.cs 313 | *.btm.cs 314 | *.odx.cs 315 | *.xsd.cs 316 | 317 | # OpenCover UI analysis results 318 | OpenCover/ 319 | 320 | # Azure Stream Analytics local run output 321 | ASALocalRun/ 322 | 323 | # MSBuild Binary and Structured Log 324 | *.binlog 325 | 326 | # NVidia Nsight GPU debugger configuration file 327 | *.nvuser 328 | 329 | # MFractors (Xamarin productivity tool) working folder 330 | .mfractor/ -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | - Employees can reach out at [aka.ms/opensource/moderation-support](https://aka.ms/opensource/moderation-support) 11 | -------------------------------------------------------------------------------- /HowToBuild.md: -------------------------------------------------------------------------------- 1 | **Build the action** 2 | 3 | Open PowerShell, go to the directory where the repo is stored (.../cli/) and execute the following commands. 4 | 5 | **1.npm install** \ 6 | npm install downloads dependencies defined in a package. json file and generates a node_modules folder with the installed modules. \ 7 | **2.npm install -g @vercel/ncc** \ 8 | **3.ncc build src/main.ts -s -o _build** \ 9 | ncc is a simple CLI for compiling a Node.js module into a single file, together with all its dependencies, gcc-style. \ 10 | 11 | This builds the solution and create the required .js file(s). Good to go! -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 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 Action for Azure CLI 2 | 3 | > [!WARNING] 4 | > Starting with Azure CLI version `2.64.0`, the Azure CLI docker image will be based on Azure Linux. The `az` commands are not affected by this change. To ensure the compatibility of your pipelines, please migrate Alpine-specific commands to Azure Linux commands in the scripts used in the azure/cli action. 5 | > 6 | > For more information, see https://go.microsoft.com/fwlink/?linkid=2282203. 7 | 8 | With Azure CLI GitHub Action, you can automate your workflow by executing [Azure CLI](https://github.com/Azure/azure-cli) commands to manage Azure resources inside of an Action. 9 | 10 | The action executes the Azure CLI Bash script on a user defined Azure CLI version. If the user does not specify a version, the version of Azure CLI installed on the agent is used. If there is no version of Azure CLI found on the agent, the action falls back the version to `latest`. 11 | Read more about various Azure CLI versions [here](https://github.com/Azure/azure-cli/releases). 12 | 13 | - `azcliversion` – **Optional** Example: 2.30.0, Default: set to az cli version of the agent. 14 | - `inlineScript` – **Required** 15 | 16 | Azure CLI GitHub Action is supported for the Azure public cloud as well as Azure government clouds ('AzureUSGovernment' or 'AzureChinaCloud') and Azure Stack ('AzureStack') Hub. Before running this action, login to the respective Azure Cloud using [Azure Login](https://github.com/Azure/login) by setting appropriate value for the `environment` parameter. 17 | 18 | The definition of this GitHub Action is in [action.yml](https://github.com/Azure/CLI/blob/master/action.yml). The action status is determined by the exit code returned by the script rather than StandardError stream. 19 | 20 | > [!NOTE] 21 | > Please note that the action executes Azure CLI script in a docker container. This means that the action is subjected to potential restrictions which arise from containerized execution. For example: 22 | > 1. If script sets up an environment variable, it will not take effect in host and hence subsequent actions shouldn't rely on such environment variable. 23 | > 2. There is some restriction on how cross action file read/write is done. `GITHUB_WORKSPACE` directory in host is mapped to working directory inside container. So, if the action wants to create a file, which will be read by subsequent actions, it should do so within current working directory tree. 24 | 25 | > [!WARNING] 26 | > By default, the output of Azure CLI commands is printed to the stdout stream. Without redirecting the stdout stream, contents in it will be stored in the build log of the action. Configure Azure CLI to _not_ show output in the console screen or print in the log by setting the environment variable `AZURE_CORE_OUTPUT` to `none`. If you need the output of a specific command, override the default setting using the argument `--output` with your format of choice. For more information on output options with the Azure CLI, see [Format output](https://learn.microsoft.com/cli/azure/format-output-azure-cli). 27 | 28 | ## Sample workflow 29 | 30 | ### Dependencies on other GitHub Actions 31 | * [Azure Login](https://github.com/Azure/login) – **Optional** Login with your Azure credentials, required only for authentication via Azure credentials. If you use this action, make sure to either use the default value of `azcliversion` or `azcliversion >= 2.30.0` for all the workflows. Authentication via connection strings or keys do not require this step. 32 | * [Checkout](https://github.com/actions/checkout) – **Optional** To execute the scripts present in your repository. 33 | 34 | ### Workflow to execute an Azure CLI script of the latest Azure CLI version 35 | ```yaml 36 | # File: .github/workflows/workflow.yml 37 | 38 | on: [push] 39 | 40 | name: AzureCLISample 41 | 42 | jobs: 43 | 44 | build-and-deploy: 45 | runs-on: ubuntu-latest 46 | steps: 47 | 48 | - name: Azure Login 49 | uses: azure/login@v2 50 | with: 51 | creds: ${{ secrets.AZURE_CREDENTIALS }} 52 | 53 | - name: Azure CLI script 54 | uses: azure/cli@v2 55 | with: 56 | azcliversion: latest 57 | inlineScript: | 58 | az account show 59 | az storage -h 60 | ``` 61 | 62 | ### Workflow to execute an Azure CLI script of a specific CLI version via file present in your repository. 63 | ```yaml 64 | # File: .github/workflows/workflowForFile.yml 65 | 66 | on: [push] 67 | 68 | name: AzureCLISampleForFile 69 | 70 | jobs: 71 | 72 | build-and-deploy: 73 | runs-on: ubuntu-latest 74 | steps: 75 | 76 | - name: Azure Login 77 | uses: azure/login@v2 78 | with: 79 | creds: ${{ secrets.AZURE_CREDENTIALS }} 80 | 81 | - name: Checkout 82 | uses: actions/checkout@v4 83 | 84 | - name: Azure CLI script file 85 | uses: azure/cli@v2 86 | with: 87 | azcliversion: 2.30.0 88 | inlineScript: | 89 | chmod +x $GITHUB_WORKSPACE/sampleScript.sh 90 | $GITHUB_WORKSPACE/sampleScript.sh 91 | ``` 92 | * [`GITHUB_WORKSPACE`](https://docs.github.com/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#file-systems) is the environment variable provided by GitHub which represents the root of your repository. 93 | 94 | # Getting Help for Azure CLI Issues 95 | 96 | If you encounter an issue related to the Azure CLI commands executed in your script, you can file an issue directly on the [Azure CLI repository](https://github.com/Azure/azure-cli/issues/new/choose). 97 | 98 | # Contributing 99 | 100 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 101 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 102 | the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. 103 | 104 | When you submit a pull request, a CLA bot will automatically determine whether you need to provide 105 | a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions 106 | provided by the bot. You will only need to do this once across all repos using our CLA. 107 | 108 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 109 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 110 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 111 | -------------------------------------------------------------------------------- /ReleaseProcess.md: -------------------------------------------------------------------------------- 1 | **Releasing a new version** 2 | 3 | Semanting versioning is used to release different versions of the action. Following steps are to be followed : 4 | 5 | 1. Create a new branch for every major version. \ 6 | Example, releases/v1, releases/v2. 7 | 2. For every minor and patch release for a major version, update the corresponding release branch. \ 8 | Example, for releasing v1.1.1, update releases/v1. 9 | 3. Create tags for every new release (major/minor/patch). \ 10 | Example,v1.0.0. , v1.0.1, v2.0.1, etc. and also have tags like v1, v2 for every major version release. 11 | 4. On releasing minor and patch versions, update the tag of the corresponding major version. \ 12 | Example, for releasing v1.0.1, update the v1 tag to point to the ref of the current release. \ 13 | The following commands are to be run on the release\v1 branch so that it picks the latest commit and updates the v1 tag accordingly : 14 | (Ensure that you are on same commit locally as you want to release) 15 | * `git tag -fa v1 -m "Update v1 tag"` 16 | * `git push origin v1 --force` 17 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets Microsoft's [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)) of a security vulnerability, please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | # Azure CLI Action 2 | name: 'Azure CLI Action' 3 | description: 'Automate your GitHub workflows using Azure CLI scripts.' 4 | inputs: 5 | inlineScript: 6 | description: 'Specify the script here' 7 | required: true 8 | azcliversion: 9 | description: 'Azure CLI version to be used to execute the script. If not provided, latest version is used' 10 | required: false 11 | default: 'agentazcliversion' 12 | branding: 13 | icon: 'login.svg' 14 | color: 'blue' 15 | runs: 16 | using: 'node20' 17 | main: 'dist/index.js' 18 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | (()=>{var e={175:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;Object.defineProperty(e,n,{enumerable:true,get:function(){return t[r]}})}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.hasOwnProperty.call(e,r))n(t,e,r);i(t,e);return t};Object.defineProperty(t,"__esModule",{value:true});t.issue=t.issueCommand=void 0;const s=o(r(857));const a=r(443);function issueCommand(e,t,r){const n=new Command(e,t,r);process.stdout.write(n.toString()+s.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const u="::";class Command{constructor(e,t,r){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=r}toString(){let e=u+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=true;for(const r in this.properties){if(this.properties.hasOwnProperty(r)){const n=this.properties[r];if(n){if(t){t=false}else{e+=","}e+=`${r}=${escapeProperty(n)}`}}}}e+=`${u}${escapeData(this.message)}`;return e}}function escapeData(e){return a.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return a.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},167:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;Object.defineProperty(e,n,{enumerable:true,get:function(){return t[r]}})}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.hasOwnProperty.call(e,r))n(t,e,r);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});t.getIDToken=t.getState=t.saveState=t.group=t.endGroup=t.startGroup=t.info=t.notice=t.warning=t.error=t.debug=t.isDebug=t.setFailed=t.setCommandEcho=t.setOutput=t.getBooleanInput=t.getMultilineInput=t.getInput=t.addPath=t.setSecret=t.exportVariable=t.ExitCode=void 0;const a=r(175);const u=r(538);const c=r(443);const l=o(r(857));const d=o(r(928));const f=r(229);var p;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(p=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){const r=c.toCommandValue(t);process.env[e]=r;const n=process.env["GITHUB_ENV"]||"";if(n){return u.issueFileCommand("ENV",u.prepareKeyValueMessage(e,t))}a.issueCommand("set-env",{name:e},r)}t.exportVariable=exportVariable;function setSecret(e){a.issueCommand("add-mask",{},e)}t.setSecret=setSecret;function addPath(e){const t=process.env["GITHUB_PATH"]||"";if(t){u.issueFileCommand("PATH",e)}else{a.issueCommand("add-path",{},e)}process.env["PATH"]=`${e}${d.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const r=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!r){throw new Error(`Input required and not supplied: ${e}`)}if(t&&t.trimWhitespace===false){return r}return r.trim()}t.getInput=getInput;function getMultilineInput(e,t){const r=getInput(e,t).split("\n").filter((e=>e!==""));if(t&&t.trimWhitespace===false){return r}return r.map((e=>e.trim()))}t.getMultilineInput=getMultilineInput;function getBooleanInput(e,t){const r=["true","True","TRUE"];const n=["false","False","FALSE"];const i=getInput(e,t);if(r.includes(i))return true;if(n.includes(i))return false;throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${e}\n`+`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``)}t.getBooleanInput=getBooleanInput;function setOutput(e,t){const r=process.env["GITHUB_OUTPUT"]||"";if(r){return u.issueFileCommand("OUTPUT",u.prepareKeyValueMessage(e,t))}process.stdout.write(l.EOL);a.issueCommand("set-output",{name:e},c.toCommandValue(t))}t.setOutput=setOutput;function setCommandEcho(e){a.issue("echo",e?"on":"off")}t.setCommandEcho=setCommandEcho;function setFailed(e){process.exitCode=p.Failure;error(e)}t.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}t.isDebug=isDebug;function debug(e){a.issueCommand("debug",{},e)}t.debug=debug;function error(e,t={}){a.issueCommand("error",c.toCommandProperties(t),e instanceof Error?e.toString():e)}t.error=error;function warning(e,t={}){a.issueCommand("warning",c.toCommandProperties(t),e instanceof Error?e.toString():e)}t.warning=warning;function notice(e,t={}){a.issueCommand("notice",c.toCommandProperties(t),e instanceof Error?e.toString():e)}t.notice=notice;function info(e){process.stdout.write(e+l.EOL)}t.info=info;function startGroup(e){a.issue("group",e)}t.startGroup=startGroup;function endGroup(){a.issue("endgroup")}t.endGroup=endGroup;function group(e,t){return s(this,void 0,void 0,(function*(){startGroup(e);let r;try{r=yield t()}finally{endGroup()}return r}))}t.group=group;function saveState(e,t){const r=process.env["GITHUB_STATE"]||"";if(r){return u.issueFileCommand("STATE",u.prepareKeyValueMessage(e,t))}a.issueCommand("save-state",{name:e},c.toCommandValue(t))}t.saveState=saveState;function getState(e){return process.env[`STATE_${e}`]||""}t.getState=getState;function getIDToken(e){return s(this,void 0,void 0,(function*(){return yield f.OidcClient.getIDToken(e)}))}t.getIDToken=getIDToken;var h=r(622);Object.defineProperty(t,"summary",{enumerable:true,get:function(){return h.summary}});var m=r(622);Object.defineProperty(t,"markdownSummary",{enumerable:true,get:function(){return m.markdownSummary}});var v=r(571);Object.defineProperty(t,"toPosixPath",{enumerable:true,get:function(){return v.toPosixPath}});Object.defineProperty(t,"toWin32Path",{enumerable:true,get:function(){return v.toWin32Path}});Object.defineProperty(t,"toPlatformPath",{enumerable:true,get:function(){return v.toPlatformPath}})},538:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;Object.defineProperty(e,n,{enumerable:true,get:function(){return t[r]}})}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.hasOwnProperty.call(e,r))n(t,e,r);i(t,e);return t};Object.defineProperty(t,"__esModule",{value:true});t.prepareKeyValueMessage=t.issueFileCommand=void 0;const s=o(r(896));const a=o(r(857));const u=r(549);const c=r(443);function issueFileCommand(e,t){const r=process.env[`GITHUB_${e}`];if(!r){throw new Error(`Unable to find environment variable for file command ${e}`)}if(!s.existsSync(r)){throw new Error(`Missing file at path: ${r}`)}s.appendFileSync(r,`${c.toCommandValue(t)}${a.EOL}`,{encoding:"utf8"})}t.issueFileCommand=issueFileCommand;function prepareKeyValueMessage(e,t){const r=`ghadelimiter_${u.v4()}`;const n=c.toCommandValue(t);if(e.includes(r)){throw new Error(`Unexpected input: name should not contain the delimiter "${r}"`)}if(n.includes(r)){throw new Error(`Unexpected input: value should not contain the delimiter "${r}"`)}return`${e}<<${r}${a.EOL}${n}${a.EOL}${r}`}t.prepareKeyValueMessage=prepareKeyValueMessage},229:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});t.OidcClient=void 0;const i=r(991);const o=r(253);const s=r(167);class OidcClient{static createHttpClient(e=true,t=10){const r={allowRetries:e,maxRetries:t};return new i.HttpClient("actions/oidc-client",[new o.BearerCredentialHandler(OidcClient.getRequestToken())],r)}static getRequestToken(){const e=process.env["ACTIONS_ID_TOKEN_REQUEST_TOKEN"];if(!e){throw new Error("Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable")}return e}static getIDTokenUrl(){const e=process.env["ACTIONS_ID_TOKEN_REQUEST_URL"];if(!e){throw new Error("Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable")}return e}static getCall(e){var t;return n(this,void 0,void 0,(function*(){const r=OidcClient.createHttpClient();const n=yield r.getJson(e).catch((e=>{throw new Error(`Failed to get ID Token. \n \n Error Code : ${e.statusCode}\n \n Error Message: ${e.result.message}`)}));const i=(t=n.result)===null||t===void 0?void 0:t.value;if(!i){throw new Error("Response json body do not have ID Token field")}return i}))}static getIDToken(e){return n(this,void 0,void 0,(function*(){try{let t=OidcClient.getIDTokenUrl();if(e){const r=encodeURIComponent(e);t=`${t}&audience=${r}`}s.debug(`ID token url is ${t}`);const r=yield OidcClient.getCall(t);s.setSecret(r);return r}catch(e){throw new Error(`Error message: ${e.message}`)}}))}}t.OidcClient=OidcClient},571:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;Object.defineProperty(e,n,{enumerable:true,get:function(){return t[r]}})}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.hasOwnProperty.call(e,r))n(t,e,r);i(t,e);return t};Object.defineProperty(t,"__esModule",{value:true});t.toPlatformPath=t.toWin32Path=t.toPosixPath=void 0;const s=o(r(928));function toPosixPath(e){return e.replace(/[\\]/g,"/")}t.toPosixPath=toPosixPath;function toWin32Path(e){return e.replace(/[/]/g,"\\")}t.toWin32Path=toWin32Path;function toPlatformPath(e){return e.replace(/[/\\]/g,s.sep)}t.toPlatformPath=toPlatformPath},622:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});t.summary=t.markdownSummary=t.SUMMARY_DOCS_URL=t.SUMMARY_ENV_VAR=void 0;const i=r(857);const o=r(896);const{access:s,appendFile:a,writeFile:u}=o.promises;t.SUMMARY_ENV_VAR="GITHUB_STEP_SUMMARY";t.SUMMARY_DOCS_URL="https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";class Summary{constructor(){this._buffer=""}filePath(){return n(this,void 0,void 0,(function*(){if(this._filePath){return this._filePath}const e=process.env[t.SUMMARY_ENV_VAR];if(!e){throw new Error(`Unable to find environment variable for $${t.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`)}try{yield s(e,o.constants.R_OK|o.constants.W_OK)}catch(t){throw new Error(`Unable to access summary file: '${e}'. Check if the file has correct read/write permissions.`)}this._filePath=e;return this._filePath}))}wrap(e,t,r={}){const n=Object.entries(r).map((([e,t])=>` ${e}="${t}"`)).join("");if(!t){return`<${e}${n}>`}return`<${e}${n}>${t}`}write(e){return n(this,void 0,void 0,(function*(){const t=!!(e===null||e===void 0?void 0:e.overwrite);const r=yield this.filePath();const n=t?u:a;yield n(r,this._buffer,{encoding:"utf8"});return this.emptyBuffer()}))}clear(){return n(this,void 0,void 0,(function*(){return this.emptyBuffer().write({overwrite:true})}))}stringify(){return this._buffer}isEmptyBuffer(){return this._buffer.length===0}emptyBuffer(){this._buffer="";return this}addRaw(e,t=false){this._buffer+=e;return t?this.addEOL():this}addEOL(){return this.addRaw(i.EOL)}addCodeBlock(e,t){const r=Object.assign({},t&&{lang:t});const n=this.wrap("pre",this.wrap("code",e),r);return this.addRaw(n).addEOL()}addList(e,t=false){const r=t?"ol":"ul";const n=e.map((e=>this.wrap("li",e))).join("");const i=this.wrap(r,n);return this.addRaw(i).addEOL()}addTable(e){const t=e.map((e=>{const t=e.map((e=>{if(typeof e==="string"){return this.wrap("td",e)}const{header:t,data:r,colspan:n,rowspan:i}=e;const o=t?"th":"td";const s=Object.assign(Object.assign({},n&&{colspan:n}),i&&{rowspan:i});return this.wrap(o,r,s)})).join("");return this.wrap("tr",t)})).join("");const r=this.wrap("table",t);return this.addRaw(r).addEOL()}addDetails(e,t){const r=this.wrap("details",this.wrap("summary",e)+t);return this.addRaw(r).addEOL()}addImage(e,t,r){const{width:n,height:i}=r||{};const o=Object.assign(Object.assign({},n&&{width:n}),i&&{height:i});const s=this.wrap("img",null,Object.assign({src:e,alt:t},o));return this.addRaw(s).addEOL()}addHeading(e,t){const r=`h${t}`;const n=["h1","h2","h3","h4","h5","h6"].includes(r)?r:"h1";const i=this.wrap(n,e);return this.addRaw(i).addEOL()}addSeparator(){const e=this.wrap("hr",null);return this.addRaw(e).addEOL()}addBreak(){const e=this.wrap("br",null);return this.addRaw(e).addEOL()}addQuote(e,t){const r=Object.assign({},t&&{cite:t});const n=this.wrap("blockquote",e,r);return this.addRaw(n).addEOL()}addLink(e,t){const r=this.wrap("a",e,{href:t});return this.addRaw(r).addEOL()}}const c=new Summary;t.markdownSummary=c;t.summary=c},443:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.toCommandProperties=t.toCommandValue=void 0;function toCommandValue(e){if(e===null||e===undefined){return""}else if(typeof e==="string"||e instanceof String){return e}return JSON.stringify(e)}t.toCommandValue=toCommandValue;function toCommandProperties(e){if(!Object.keys(e).length){return{}}return{title:e.title,file:e.file,line:e.startLine,endLine:e.endLine,col:e.startColumn,endColumn:e.endColumn}}t.toCommandProperties=toCommandProperties},471:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});const i=r(682);function exec(e,t,r){return n(this,void 0,void 0,(function*(){const n=i.argStringToArray(e);if(n.length===0){throw new Error(`Parameter 'commandLine' cannot be null or empty.`)}const o=n[0];t=n.slice(1).concat(t||[]);const s=new i.ToolRunner(o,t,r);return s.exec()}))}t.exec=exec},682:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});const i=r(857);const o=r(53);const s=r(317);const a=process.platform==="win32";class ToolRunner extends o.EventEmitter{constructor(e,t,r){super();if(!e){throw new Error("Parameter 'toolPath' cannot be null or empty.")}this.toolPath=e;this.args=t||[];this.options=r||{}}_debug(e){if(this.options.listeners&&this.options.listeners.debug){this.options.listeners.debug(e)}}_getCommandString(e,t){const r=this._getSpawnFileName();const n=this._getSpawnArgs(e);let i=t?"":"[command]";if(a){if(this._isCmdFile()){i+=r;for(const e of n){i+=` ${e}`}}else if(e.windowsVerbatimArguments){i+=`"${r}"`;for(const e of n){i+=` ${e}`}}else{i+=this._windowsQuoteCmdArg(r);for(const e of n){i+=` ${this._windowsQuoteCmdArg(e)}`}}}else{i+=r;for(const e of n){i+=` ${e}`}}return i}_processLineBuffer(e,t,r){try{let n=t+e.toString();let o=n.indexOf(i.EOL);while(o>-1){const e=n.substring(0,o);r(e);n=n.substring(o+i.EOL.length);o=n.indexOf(i.EOL)}t=n}catch(e){this._debug(`error processing line. Failed with error ${e}`)}}_getSpawnFileName(){if(a){if(this._isCmdFile()){return process.env["COMSPEC"]||"cmd.exe"}}return this.toolPath}_getSpawnArgs(e){if(a){if(this._isCmdFile()){let t=`/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;for(const r of this.args){t+=" ";t+=e.windowsVerbatimArguments?r:this._windowsQuoteCmdArg(r)}t+='"';return[t]}}return this.args}_endsWith(e,t){return e.endsWith(t)}_isCmdFile(){const e=this.toolPath.toUpperCase();return this._endsWith(e,".CMD")||this._endsWith(e,".BAT")}_windowsQuoteCmdArg(e){if(!this._isCmdFile()){return this._uvQuoteCmdArg(e)}if(!e){return'""'}const t=[" ","\t","&","(",")","[","]","{","}","^","=",";","!","'","+",",","`","~","|","<",">",'"'];let r=false;for(const n of e){if(t.some((e=>e===n))){r=true;break}}if(!r){return e}let n='"';let i=true;for(let t=e.length;t>0;t--){n+=e[t-1];if(i&&e[t-1]==="\\"){n+="\\"}else if(e[t-1]==='"'){i=true;n+='"'}else{i=false}}n+='"';return n.split("").reverse().join("")}_uvQuoteCmdArg(e){if(!e){return'""'}if(!e.includes(" ")&&!e.includes("\t")&&!e.includes('"')){return e}if(!e.includes('"')&&!e.includes("\\")){return`"${e}"`}let t='"';let r=true;for(let n=e.length;n>0;n--){t+=e[n-1];if(r&&e[n-1]==="\\"){t+="\\"}else if(e[n-1]==='"'){r=true;t+="\\"}else{r=false}}t+='"';return t.split("").reverse().join("")}_cloneExecOptions(e){e=e||{};const t={cwd:e.cwd||process.cwd(),env:e.env||process.env,silent:e.silent||false,windowsVerbatimArguments:e.windowsVerbatimArguments||false,failOnStdErr:e.failOnStdErr||false,ignoreReturnCode:e.ignoreReturnCode||false,delay:e.delay||1e4};t.outStream=e.outStream||process.stdout;t.errStream=e.errStream||process.stderr;return t}_getSpawnOptions(e,t){e=e||{};const r={};r.cwd=e.cwd;r.env=e.env;r["windowsVerbatimArguments"]=e.windowsVerbatimArguments||this._isCmdFile();if(e.windowsVerbatimArguments){r.argv0=`"${t}"`}return r}exec(){return n(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{this._debug(`exec tool: ${this.toolPath}`);this._debug("arguments:");for(const e of this.args){this._debug(` ${e}`)}const r=this._cloneExecOptions(this.options);if(!r.silent&&r.outStream){r.outStream.write(this._getCommandString(r)+i.EOL)}const n=new ExecState(r,this.toolPath);n.on("debug",(e=>{this._debug(e)}));const o=this._getSpawnFileName();const a=s.spawn(o,this._getSpawnArgs(r),this._getSpawnOptions(this.options,o));const u="";if(a.stdout){a.stdout.on("data",(e=>{if(this.options.listeners&&this.options.listeners.stdout){this.options.listeners.stdout(e)}if(!r.silent&&r.outStream){r.outStream.write(e)}this._processLineBuffer(e,u,(e=>{if(this.options.listeners&&this.options.listeners.stdline){this.options.listeners.stdline(e)}}))}))}const c="";if(a.stderr){a.stderr.on("data",(e=>{n.processStderr=true;if(this.options.listeners&&this.options.listeners.stderr){this.options.listeners.stderr(e)}if(!r.silent&&r.errStream&&r.outStream){const t=r.failOnStdErr?r.errStream:r.outStream;t.write(e)}this._processLineBuffer(e,c,(e=>{if(this.options.listeners&&this.options.listeners.errline){this.options.listeners.errline(e)}}))}))}a.on("error",(e=>{n.processError=e.message;n.processExited=true;n.processClosed=true;n.CheckComplete()}));a.on("exit",(e=>{n.processExitCode=e;n.processExited=true;this._debug(`Exit code ${e} received from tool '${this.toolPath}'`);n.CheckComplete()}));a.on("close",(e=>{n.processExitCode=e;n.processExited=true;n.processClosed=true;this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);n.CheckComplete()}));n.on("done",((r,n)=>{if(u.length>0){this.emit("stdline",u)}if(c.length>0){this.emit("errline",c)}a.removeAllListeners();if(r){t(r)}else{e(n)}}))}))}))}}t.ToolRunner=ToolRunner;function argStringToArray(e){const t=[];let r=false;let n=false;let i="";function append(e){if(n&&e!=='"'){i+="\\"}i+=e;n=false}for(let o=0;o0){t.push(i);i=""}continue}append(s)}if(i.length>0){t.push(i.trim())}return t}t.argStringToArray=argStringToArray;class ExecState extends o.EventEmitter{constructor(e,t){super();this.processClosed=false;this.processError="";this.processExitCode=0;this.processExited=false;this.processStderr=false;this.delay=1e4;this.done=false;this.timeout=null;if(!t){throw new Error("toolPath must not be empty")}this.options=e;this.toolPath=t;if(e.delay){this.delay=e.delay}}CheckComplete(){if(this.done){return}if(this.processClosed){this._setResult()}else if(this.processExited){this.timeout=setTimeout(ExecState.HandleTimeout,this.delay,this)}}_debug(e){this.emit("debug",e)}_setResult(){let e;if(this.processExited){if(this.processError){e=new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`)}else if(this.processExitCode!==0&&!this.options.ignoreReturnCode){e=new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`)}else if(this.processStderr&&this.options.failOnStdErr){e=new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`)}}if(this.timeout){clearTimeout(this.timeout);this.timeout=null}this.done=true;this.emit("done",e,this.processExitCode)}static HandleTimeout(e){if(e.done){return}if(!e.processClosed&&e.processExited){const t=`The STDIO streams did not close within ${e.delay/1e3} seconds of the exit event from process '${e.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;e._debug(t)}e._setResult()}}},253:function(e,t){"use strict";var r=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});t.PersonalAccessTokenCredentialHandler=t.BearerCredentialHandler=t.BasicCredentialHandler=void 0;class BasicCredentialHandler{constructor(e,t){this.username=e;this.password=t}prepareRequest(e){if(!e.headers){throw Error("The request has no headers")}e.headers["Authorization"]=`Basic ${Buffer.from(`${this.username}:${this.password}`).toString("base64")}`}canHandleAuthentication(){return false}handleAuthentication(){return r(this,void 0,void 0,(function*(){throw new Error("not implemented")}))}}t.BasicCredentialHandler=BasicCredentialHandler;class BearerCredentialHandler{constructor(e){this.token=e}prepareRequest(e){if(!e.headers){throw Error("The request has no headers")}e.headers["Authorization"]=`Bearer ${this.token}`}canHandleAuthentication(){return false}handleAuthentication(){return r(this,void 0,void 0,(function*(){throw new Error("not implemented")}))}}t.BearerCredentialHandler=BearerCredentialHandler;class PersonalAccessTokenCredentialHandler{constructor(e){this.token=e}prepareRequest(e){if(!e.headers){throw Error("The request has no headers")}e.headers["Authorization"]=`Basic ${Buffer.from(`PAT:${this.token}`).toString("base64")}`}canHandleAuthentication(){return false}handleAuthentication(){return r(this,void 0,void 0,(function*(){throw new Error("not implemented")}))}}t.PersonalAccessTokenCredentialHandler=PersonalAccessTokenCredentialHandler},991:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;Object.defineProperty(e,n,{enumerable:true,get:function(){return t[r]}})}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.hasOwnProperty.call(e,r))n(t,e,r);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});t.HttpClient=t.isHttps=t.HttpClientResponse=t.HttpClientError=t.getProxyUrl=t.MediaTypes=t.Headers=t.HttpCodes=void 0;const a=o(r(611));const u=o(r(692));const c=o(r(779));const l=o(r(889));var d;(function(e){e[e["OK"]=200]="OK";e[e["MultipleChoices"]=300]="MultipleChoices";e[e["MovedPermanently"]=301]="MovedPermanently";e[e["ResourceMoved"]=302]="ResourceMoved";e[e["SeeOther"]=303]="SeeOther";e[e["NotModified"]=304]="NotModified";e[e["UseProxy"]=305]="UseProxy";e[e["SwitchProxy"]=306]="SwitchProxy";e[e["TemporaryRedirect"]=307]="TemporaryRedirect";e[e["PermanentRedirect"]=308]="PermanentRedirect";e[e["BadRequest"]=400]="BadRequest";e[e["Unauthorized"]=401]="Unauthorized";e[e["PaymentRequired"]=402]="PaymentRequired";e[e["Forbidden"]=403]="Forbidden";e[e["NotFound"]=404]="NotFound";e[e["MethodNotAllowed"]=405]="MethodNotAllowed";e[e["NotAcceptable"]=406]="NotAcceptable";e[e["ProxyAuthenticationRequired"]=407]="ProxyAuthenticationRequired";e[e["RequestTimeout"]=408]="RequestTimeout";e[e["Conflict"]=409]="Conflict";e[e["Gone"]=410]="Gone";e[e["TooManyRequests"]=429]="TooManyRequests";e[e["InternalServerError"]=500]="InternalServerError";e[e["NotImplemented"]=501]="NotImplemented";e[e["BadGateway"]=502]="BadGateway";e[e["ServiceUnavailable"]=503]="ServiceUnavailable";e[e["GatewayTimeout"]=504]="GatewayTimeout"})(d=t.HttpCodes||(t.HttpCodes={}));var f;(function(e){e["Accept"]="accept";e["ContentType"]="content-type"})(f=t.Headers||(t.Headers={}));var p;(function(e){e["ApplicationJson"]="application/json"})(p=t.MediaTypes||(t.MediaTypes={}));function getProxyUrl(e){const t=c.getProxyUrl(new URL(e));return t?t.href:""}t.getProxyUrl=getProxyUrl;const h=[d.MovedPermanently,d.ResourceMoved,d.SeeOther,d.TemporaryRedirect,d.PermanentRedirect];const m=[d.BadGateway,d.ServiceUnavailable,d.GatewayTimeout];const v=["OPTIONS","GET","DELETE","HEAD"];const _=10;const g=5;class HttpClientError extends Error{constructor(e,t){super(e);this.name="HttpClientError";this.statusCode=t;Object.setPrototypeOf(this,HttpClientError.prototype)}}t.HttpClientError=HttpClientError;class HttpClientResponse{constructor(e){this.message=e}readBody(){return s(this,void 0,void 0,(function*(){return new Promise((e=>s(this,void 0,void 0,(function*(){let t=Buffer.alloc(0);this.message.on("data",(e=>{t=Buffer.concat([t,e])}));this.message.on("end",(()=>{e(t.toString())}))}))))}))}}t.HttpClientResponse=HttpClientResponse;function isHttps(e){const t=new URL(e);return t.protocol==="https:"}t.isHttps=isHttps;class HttpClient{constructor(e,t,r){this._ignoreSslError=false;this._allowRedirects=true;this._allowRedirectDowngrade=false;this._maxRedirects=50;this._allowRetries=false;this._maxRetries=1;this._keepAlive=false;this._disposed=false;this.userAgent=e;this.handlers=t||[];this.requestOptions=r;if(r){if(r.ignoreSslError!=null){this._ignoreSslError=r.ignoreSslError}this._socketTimeout=r.socketTimeout;if(r.allowRedirects!=null){this._allowRedirects=r.allowRedirects}if(r.allowRedirectDowngrade!=null){this._allowRedirectDowngrade=r.allowRedirectDowngrade}if(r.maxRedirects!=null){this._maxRedirects=Math.max(r.maxRedirects,0)}if(r.keepAlive!=null){this._keepAlive=r.keepAlive}if(r.allowRetries!=null){this._allowRetries=r.allowRetries}if(r.maxRetries!=null){this._maxRetries=r.maxRetries}}}options(e,t){return s(this,void 0,void 0,(function*(){return this.request("OPTIONS",e,null,t||{})}))}get(e,t){return s(this,void 0,void 0,(function*(){return this.request("GET",e,null,t||{})}))}del(e,t){return s(this,void 0,void 0,(function*(){return this.request("DELETE",e,null,t||{})}))}post(e,t,r){return s(this,void 0,void 0,(function*(){return this.request("POST",e,t,r||{})}))}patch(e,t,r){return s(this,void 0,void 0,(function*(){return this.request("PATCH",e,t,r||{})}))}put(e,t,r){return s(this,void 0,void 0,(function*(){return this.request("PUT",e,t,r||{})}))}head(e,t){return s(this,void 0,void 0,(function*(){return this.request("HEAD",e,null,t||{})}))}sendStream(e,t,r,n){return s(this,void 0,void 0,(function*(){return this.request(e,t,r,n)}))}getJson(e,t={}){return s(this,void 0,void 0,(function*(){t[f.Accept]=this._getExistingOrDefaultHeader(t,f.Accept,p.ApplicationJson);const r=yield this.get(e,t);return this._processResponse(r,this.requestOptions)}))}postJson(e,t,r={}){return s(this,void 0,void 0,(function*(){const n=JSON.stringify(t,null,2);r[f.Accept]=this._getExistingOrDefaultHeader(r,f.Accept,p.ApplicationJson);r[f.ContentType]=this._getExistingOrDefaultHeader(r,f.ContentType,p.ApplicationJson);const i=yield this.post(e,n,r);return this._processResponse(i,this.requestOptions)}))}putJson(e,t,r={}){return s(this,void 0,void 0,(function*(){const n=JSON.stringify(t,null,2);r[f.Accept]=this._getExistingOrDefaultHeader(r,f.Accept,p.ApplicationJson);r[f.ContentType]=this._getExistingOrDefaultHeader(r,f.ContentType,p.ApplicationJson);const i=yield this.put(e,n,r);return this._processResponse(i,this.requestOptions)}))}patchJson(e,t,r={}){return s(this,void 0,void 0,(function*(){const n=JSON.stringify(t,null,2);r[f.Accept]=this._getExistingOrDefaultHeader(r,f.Accept,p.ApplicationJson);r[f.ContentType]=this._getExistingOrDefaultHeader(r,f.ContentType,p.ApplicationJson);const i=yield this.patch(e,n,r);return this._processResponse(i,this.requestOptions)}))}request(e,t,r,n){return s(this,void 0,void 0,(function*(){if(this._disposed){throw new Error("Client has already been disposed.")}const i=new URL(t);let o=this._prepareRequest(e,i,n);const s=this._allowRetries&&v.includes(e)?this._maxRetries+1:1;let a=0;let u;do{u=yield this.requestRaw(o,r);if(u&&u.message&&u.message.statusCode===d.Unauthorized){let e;for(const t of this.handlers){if(t.canHandleAuthentication(u)){e=t;break}}if(e){return e.handleAuthentication(this,o,r)}else{return u}}let t=this._maxRedirects;while(u.message.statusCode&&h.includes(u.message.statusCode)&&this._allowRedirects&&t>0){const s=u.message.headers["location"];if(!s){break}const a=new URL(s);if(i.protocol==="https:"&&i.protocol!==a.protocol&&!this._allowRedirectDowngrade){throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.")}yield u.readBody();if(a.hostname!==i.hostname){for(const e in n){if(e.toLowerCase()==="authorization"){delete n[e]}}}o=this._prepareRequest(e,a,n);u=yield this.requestRaw(o,r);t--}if(!u.message.statusCode||!m.includes(u.message.statusCode)){return u}a+=1;if(a{function callbackForResult(e,t){if(e){n(e)}else if(!t){n(new Error("Unknown error"))}else{r(t)}}this.requestRawWithCallback(e,t,callbackForResult)}))}))}requestRawWithCallback(e,t,r){if(typeof t==="string"){if(!e.options.headers){e.options.headers={}}e.options.headers["Content-Length"]=Buffer.byteLength(t,"utf8")}let n=false;function handleResult(e,t){if(!n){n=true;r(e,t)}}const i=e.httpModule.request(e.options,(e=>{const t=new HttpClientResponse(e);handleResult(undefined,t)}));let o;i.on("socket",(e=>{o=e}));i.setTimeout(this._socketTimeout||3*6e4,(()=>{if(o){o.end()}handleResult(new Error(`Request timeout: ${e.options.path}`))}));i.on("error",(function(e){handleResult(e)}));if(t&&typeof t==="string"){i.write(t,"utf8")}if(t&&typeof t!=="string"){t.on("close",(function(){i.end()}));t.pipe(i)}else{i.end()}}getAgent(e){const t=new URL(e);return this._getAgent(t)}_prepareRequest(e,t,r){const n={};n.parsedUrl=t;const i=n.parsedUrl.protocol==="https:";n.httpModule=i?u:a;const o=i?443:80;n.options={};n.options.host=n.parsedUrl.hostname;n.options.port=n.parsedUrl.port?parseInt(n.parsedUrl.port):o;n.options.path=(n.parsedUrl.pathname||"")+(n.parsedUrl.search||"");n.options.method=e;n.options.headers=this._mergeHeaders(r);if(this.userAgent!=null){n.options.headers["user-agent"]=this.userAgent}n.options.agent=this._getAgent(n.parsedUrl);if(this.handlers){for(const e of this.handlers){e.prepareRequest(n.options)}}return n}_mergeHeaders(e){if(this.requestOptions&&this.requestOptions.headers){return Object.assign({},lowercaseKeys(this.requestOptions.headers),lowercaseKeys(e||{}))}return lowercaseKeys(e||{})}_getExistingOrDefaultHeader(e,t,r){let n;if(this.requestOptions&&this.requestOptions.headers){n=lowercaseKeys(this.requestOptions.headers)[t]}return e[t]||n||r}_getAgent(e){let t;const r=c.getProxyUrl(e);const n=r&&r.hostname;if(this._keepAlive&&n){t=this._proxyAgent}if(this._keepAlive&&!n){t=this._agent}if(t){return t}const i=e.protocol==="https:";let o=100;if(this.requestOptions){o=this.requestOptions.maxSockets||a.globalAgent.maxSockets}if(r&&r.hostname){const e={maxSockets:o,keepAlive:this._keepAlive,proxy:Object.assign(Object.assign({},(r.username||r.password)&&{proxyAuth:`${r.username}:${r.password}`}),{host:r.hostname,port:r.port})};let n;const s=r.protocol==="https:";if(i){n=s?l.httpsOverHttps:l.httpsOverHttp}else{n=s?l.httpOverHttps:l.httpOverHttp}t=n(e);this._proxyAgent=t}if(this._keepAlive&&!t){const e={keepAlive:this._keepAlive,maxSockets:o};t=i?new u.Agent(e):new a.Agent(e);this._agent=t}if(!t){t=i?u.globalAgent:a.globalAgent}if(i&&this._ignoreSslError){t.options=Object.assign(t.options||{},{rejectUnauthorized:false})}return t}_performExponentialBackoff(e){return s(this,void 0,void 0,(function*(){e=Math.min(_,e);const t=g*Math.pow(2,e);return new Promise((e=>setTimeout((()=>e()),t)))}))}_processResponse(e,t){return s(this,void 0,void 0,(function*(){return new Promise(((r,n)=>s(this,void 0,void 0,(function*(){const i=e.message.statusCode||0;const o={statusCode:i,result:null,headers:{}};if(i===d.NotFound){r(o)}function dateTimeDeserializer(e,t){if(typeof t==="string"){const e=new Date(t);if(!isNaN(e.valueOf())){return e}}return t}let s;let a;try{a=yield e.readBody();if(a&&a.length>0){if(t&&t.deserializeDates){s=JSON.parse(a,dateTimeDeserializer)}else{s=JSON.parse(a)}o.result=s}o.headers=e.message.headers}catch(e){}if(i>299){let e;if(s&&s.message){e=s.message}else if(a&&a.length>0){e=a}else{e=`Failed request: (${i})`}const t=new HttpClientError(e,i);t.result=o.result;n(t)}else{r(o)}}))))}))}}t.HttpClient=HttpClient;const lowercaseKeys=e=>Object.keys(e).reduce(((t,r)=>(t[r.toLowerCase()]=e[r],t)),{})},779:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.checkBypass=t.getProxyUrl=void 0;function getProxyUrl(e){const t=e.protocol==="https:";if(checkBypass(e)){return undefined}const r=(()=>{if(t){return process.env["https_proxy"]||process.env["HTTPS_PROXY"]}else{return process.env["http_proxy"]||process.env["HTTP_PROXY"]}})();if(r){return new URL(r)}else{return undefined}}t.getProxyUrl=getProxyUrl;function checkBypass(e){if(!e.hostname){return false}const t=process.env["no_proxy"]||process.env["NO_PROXY"]||"";if(!t){return false}let r;if(e.port){r=Number(e.port)}else if(e.protocol==="http:"){r=80}else if(e.protocol==="https:"){r=443}const n=[e.hostname.toUpperCase()];if(typeof r==="number"){n.push(`${n[0]}:${r}`)}for(const e of t.split(",").map((e=>e.trim().toUpperCase())).filter((e=>e))){if(n.some((t=>t===e))){return true}}return false}t.checkBypass=checkBypass},806:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};var i;Object.defineProperty(t,"__esModule",{value:true});const o=r(613);const s=r(896);const a=r(928);i=s.promises,t.chmod=i.chmod,t.copyFile=i.copyFile,t.lstat=i.lstat,t.mkdir=i.mkdir,t.readdir=i.readdir,t.readlink=i.readlink,t.rename=i.rename,t.rmdir=i.rmdir,t.stat=i.stat,t.symlink=i.symlink,t.unlink=i.unlink;t.IS_WINDOWS=process.platform==="win32";function exists(e){return n(this,void 0,void 0,(function*(){try{yield t.stat(e)}catch(e){if(e.code==="ENOENT"){return false}throw e}return true}))}t.exists=exists;function isDirectory(e,r=false){return n(this,void 0,void 0,(function*(){const n=r?yield t.stat(e):yield t.lstat(e);return n.isDirectory()}))}t.isDirectory=isDirectory;function isRooted(e){e=normalizeSeparators(e);if(!e){throw new Error('isRooted() parameter "p" cannot be empty')}if(t.IS_WINDOWS){return e.startsWith("\\")||/^[A-Z]:/i.test(e)}return e.startsWith("/")}t.isRooted=isRooted;function mkdirP(e,r=1e3,i=1){return n(this,void 0,void 0,(function*(){o.ok(e,"a path argument must be provided");e=a.resolve(e);if(i>=r)return t.mkdir(e);try{yield t.mkdir(e);return}catch(n){switch(n.code){case"ENOENT":{yield mkdirP(a.dirname(e),r,i+1);yield t.mkdir(e);return}default:{let r;try{r=yield t.stat(e)}catch(e){throw n}if(!r.isDirectory())throw n}}}}))}t.mkdirP=mkdirP;function tryGetExecutablePath(e,r){return n(this,void 0,void 0,(function*(){let n=undefined;try{n=yield t.stat(e)}catch(t){if(t.code!=="ENOENT"){console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}}if(n&&n.isFile()){if(t.IS_WINDOWS){const t=a.extname(e).toUpperCase();if(r.some((e=>e.toUpperCase()===t))){return e}}else{if(isUnixExecutable(n)){return e}}}const i=e;for(const o of r){e=i+o;n=undefined;try{n=yield t.stat(e)}catch(t){if(t.code!=="ENOENT"){console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}}if(n&&n.isFile()){if(t.IS_WINDOWS){try{const r=a.dirname(e);const n=a.basename(e).toUpperCase();for(const i of yield t.readdir(r)){if(n===i.toUpperCase()){e=a.join(r,i);break}}}catch(t){console.log(`Unexpected error attempting to determine the actual case of the file '${e}': ${t}`)}return e}else{if(isUnixExecutable(n)){return e}}}}return""}))}t.tryGetExecutablePath=tryGetExecutablePath;function normalizeSeparators(e){e=e||"";if(t.IS_WINDOWS){e=e.replace(/\//g,"\\");return e.replace(/\\\\+/g,"\\")}return e.replace(/\/\/+/g,"/")}function isUnixExecutable(e){return(e.mode&1)>0||(e.mode&8)>0&&e.gid===process.getgid()||(e.mode&64)>0&&e.uid===process.getuid()}},921:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});const i=r(317);const o=r(928);const s=r(23);const a=r(806);const u=s.promisify(i.exec);function cp(e,t,r={}){return n(this,void 0,void 0,(function*(){const{force:n,recursive:i}=readCopyOptions(r);const s=(yield a.exists(t))?yield a.stat(t):null;if(s&&s.isFile()&&!n){return}const u=s&&s.isDirectory()?o.join(t,o.basename(e)):t;if(!(yield a.exists(e))){throw new Error(`no such file or directory: ${e}`)}const c=yield a.stat(e);if(c.isDirectory()){if(!i){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,u,0,n)}}else{if(o.relative(e,u)===""){throw new Error(`'${u}' and '${e}' are the same file`)}yield copyFile(e,u,n)}}))}t.cp=cp;function mv(e,t,r={}){return n(this,void 0,void 0,(function*(){if(yield a.exists(t)){let n=true;if(yield a.isDirectory(t)){t=o.join(t,o.basename(e));n=yield a.exists(t)}if(n){if(r.force==null||r.force){yield rmRF(t)}else{throw new Error("Destination already exists")}}}yield mkdirP(o.dirname(t));yield a.rename(e,t)}))}t.mv=mv;function rmRF(e){return n(this,void 0,void 0,(function*(){if(a.IS_WINDOWS){try{if(yield a.isDirectory(e,true)){yield u(`rd /s /q "${e}"`)}else{yield u(`del /f /a "${e}"`)}}catch(e){if(e.code!=="ENOENT")throw e}try{yield a.unlink(e)}catch(e){if(e.code!=="ENOENT")throw e}}else{let t=false;try{t=yield a.isDirectory(e)}catch(e){if(e.code!=="ENOENT")throw e;return}if(t){yield u(`rm -rf "${e}"`)}else{yield a.unlink(e)}}}))}t.rmRF=rmRF;function mkdirP(e){return n(this,void 0,void 0,(function*(){yield a.mkdirP(e)}))}t.mkdirP=mkdirP;function which(e,t){return n(this,void 0,void 0,(function*(){if(!e){throw new Error("parameter 'tool' is required")}if(t){const t=yield which(e,false);if(!t){if(a.IS_WINDOWS){throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`)}else{throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`)}}}try{const t=[];if(a.IS_WINDOWS&&process.env.PATHEXT){for(const e of process.env.PATHEXT.split(o.delimiter)){if(e){t.push(e)}}}if(a.isRooted(e)){const r=yield a.tryGetExecutablePath(e,t);if(r){return r}return""}if(e.includes("/")||a.IS_WINDOWS&&e.includes("\\")){return""}const r=[];if(process.env.PATH){for(const e of process.env.PATH.split(o.delimiter)){if(e){r.push(e)}}}for(const n of r){const r=yield a.tryGetExecutablePath(n+o.sep+e,t);if(r){return r}}return""}catch(e){throw new Error(`which failed with message ${e.message}`)}}))}t.which=which;function readCopyOptions(e){const t=e.force==null?true:e.force;const r=Boolean(e.recursive);return{force:t,recursive:r}}function cpDirRecursive(e,t,r,i){return n(this,void 0,void 0,(function*(){if(r>=255)return;r++;yield mkdirP(t);const n=yield a.readdir(e);for(const o of n){const n=`${e}/${o}`;const s=`${t}/${o}`;const u=yield a.lstat(n);if(u.isDirectory()){yield cpDirRecursive(n,s,r,i)}else{yield copyFile(n,s,i)}}yield a.chmod(t,(yield a.stat(e)).mode)}))}function copyFile(e,t,r){return n(this,void 0,void 0,(function*(){if((yield a.lstat(e)).isSymbolicLink()){try{yield a.lstat(t);yield a.unlink(t)}catch(e){if(e.code==="EPERM"){yield a.chmod(t,"0666");yield a.unlink(t)}}const r=yield a.readlink(e);yield a.symlink(r,t,a.IS_WINDOWS?"junction":null)}else if(!(yield a.exists(t))||r){yield a.copyFile(e,t)}}))}},889:(e,t,r)=>{e.exports=r(219)},219:(e,t,r)=>{"use strict";var n=r(278);var i=r(756);var o=r(611);var s=r(692);var a=r(53);var u=r(613);var c=r(23);t.httpOverHttp=httpOverHttp;t.httpsOverHttp=httpsOverHttp;t.httpOverHttps=httpOverHttps;t.httpsOverHttps=httpsOverHttps;function httpOverHttp(e){var t=new TunnelingAgent(e);t.request=o.request;return t}function httpsOverHttp(e){var t=new TunnelingAgent(e);t.request=o.request;t.createSocket=createSecureSocket;t.defaultPort=443;return t}function httpOverHttps(e){var t=new TunnelingAgent(e);t.request=s.request;return t}function httpsOverHttps(e){var t=new TunnelingAgent(e);t.request=s.request;t.createSocket=createSecureSocket;t.defaultPort=443;return t}function TunnelingAgent(e){var t=this;t.options=e||{};t.proxyOptions=t.options.proxy||{};t.maxSockets=t.options.maxSockets||o.Agent.defaultMaxSockets;t.requests=[];t.sockets=[];t.on("free",(function onFree(e,r,n,i){var o=toOptions(r,n,i);for(var s=0,a=t.requests.length;s=this.maxSockets){i.requests.push(o);return}i.createSocket(o,(function(t){t.on("free",onFree);t.on("close",onCloseOrRemove);t.on("agentRemove",onCloseOrRemove);e.onSocket(t);function onFree(){i.emit("free",t,o)}function onCloseOrRemove(e){i.removeSocket(t);t.removeListener("free",onFree);t.removeListener("close",onCloseOrRemove);t.removeListener("agentRemove",onCloseOrRemove)}}))};TunnelingAgent.prototype.createSocket=function createSocket(e,t){var r=this;var n={};r.sockets.push(n);var i=mergeOptions({},r.proxyOptions,{method:"CONNECT",path:e.host+":"+e.port,agent:false,headers:{host:e.host+":"+e.port}});if(e.localAddress){i.localAddress=e.localAddress}if(i.proxyAuth){i.headers=i.headers||{};i.headers["Proxy-Authorization"]="Basic "+new Buffer(i.proxyAuth).toString("base64")}l("making CONNECT request");var o=r.request(i);o.useChunkedEncodingByDefault=false;o.once("response",onResponse);o.once("upgrade",onUpgrade);o.once("connect",onConnect);o.once("error",onError);o.end();function onResponse(e){e.upgrade=true}function onUpgrade(e,t,r){process.nextTick((function(){onConnect(e,t,r)}))}function onConnect(i,s,a){o.removeAllListeners();s.removeAllListeners();if(i.statusCode!==200){l("tunneling socket could not be established, statusCode=%d",i.statusCode);s.destroy();var u=new Error("tunneling socket could not be established, "+"statusCode="+i.statusCode);u.code="ECONNRESET";e.request.emit("error",u);r.removeSocket(n);return}if(a.length>0){l("got illegal response body from proxy");s.destroy();var u=new Error("got illegal response body from proxy");u.code="ECONNRESET";e.request.emit("error",u);r.removeSocket(n);return}l("tunneling connection has established");r.sockets[r.sockets.indexOf(n)]=s;return t(s)}function onError(t){o.removeAllListeners();l("tunneling socket could not be established, cause=%s\n",t.message,t.stack);var i=new Error("tunneling socket could not be established, "+"cause="+t.message);i.code="ECONNRESET";e.request.emit("error",i);r.removeSocket(n)}};TunnelingAgent.prototype.removeSocket=function removeSocket(e){var t=this.sockets.indexOf(e);if(t===-1){return}this.sockets.splice(t,1);var r=this.requests.shift();if(r){this.createSocket(r,(function(e){r.request.onSocket(e)}))}};function createSecureSocket(e,t){var r=this;TunnelingAgent.prototype.createSocket.call(r,e,(function(n){var o=e.request.getHeader("host");var s=mergeOptions({},r.options,{socket:n,servername:o?o.replace(/:.*$/,""):e.host});var a=i.connect(0,s);r.sockets[r.sockets.indexOf(n)]=a;t(a)}))}function toOptions(e,t,r){if(typeof e==="string"){return{host:e,port:t,localAddress:r}}return e}function mergeOptions(e){for(var t=1,r=arguments.length;t{"use strict";Object.defineProperty(t,"__esModule",{value:true});Object.defineProperty(t,"v1",{enumerable:true,get:function(){return n.default}});Object.defineProperty(t,"v3",{enumerable:true,get:function(){return i.default}});Object.defineProperty(t,"v4",{enumerable:true,get:function(){return o.default}});Object.defineProperty(t,"v5",{enumerable:true,get:function(){return s.default}});Object.defineProperty(t,"NIL",{enumerable:true,get:function(){return a.default}});Object.defineProperty(t,"version",{enumerable:true,get:function(){return u.default}});Object.defineProperty(t,"validate",{enumerable:true,get:function(){return c.default}});Object.defineProperty(t,"stringify",{enumerable:true,get:function(){return l.default}});Object.defineProperty(t,"parse",{enumerable:true,get:function(){return d.default}});var n=_interopRequireDefault(r(480));var i=_interopRequireDefault(r(770));var o=_interopRequireDefault(r(627));var s=_interopRequireDefault(r(332));var a=_interopRequireDefault(r(158));var u=_interopRequireDefault(r(957));var c=_interopRequireDefault(r(575));var l=_interopRequireDefault(r(580));var d=_interopRequireDefault(r(74));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}},865:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=_interopRequireDefault(r(982));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function md5(e){if(Array.isArray(e)){e=Buffer.from(e)}else if(typeof e==="string"){e=Buffer.from(e,"utf8")}return n.default.createHash("md5").update(e).digest()}var i=md5;t["default"]=i},158:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r="00000000-0000-0000-0000-000000000000";t["default"]=r},74:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=_interopRequireDefault(r(575));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function parse(e){if(!(0,n.default)(e)){throw TypeError("Invalid UUID")}let t;const r=new Uint8Array(16);r[0]=(t=parseInt(e.slice(0,8),16))>>>24;r[1]=t>>>16&255;r[2]=t>>>8&255;r[3]=t&255;r[4]=(t=parseInt(e.slice(9,13),16))>>>8;r[5]=t&255;r[6]=(t=parseInt(e.slice(14,18),16))>>>8;r[7]=t&255;r[8]=(t=parseInt(e.slice(19,23),16))>>>8;r[9]=t&255;r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255;r[11]=t/4294967296&255;r[12]=t>>>24&255;r[13]=t>>>16&255;r[14]=t>>>8&255;r[15]=t&255;return r}var i=parse;t["default"]=i},2:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var r=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;t["default"]=r},584:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=rng;var n=_interopRequireDefault(r(982));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const i=new Uint8Array(256);let o=i.length;function rng(){if(o>i.length-16){n.default.randomFillSync(i);o=0}return i.slice(o,o+=16)}},508:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=_interopRequireDefault(r(982));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function sha1(e){if(Array.isArray(e)){e=Buffer.from(e)}else if(typeof e==="string"){e=Buffer.from(e,"utf8")}return n.default.createHash("sha1").update(e).digest()}var i=sha1;t["default"]=i},580:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=_interopRequireDefault(r(575));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const i=[];for(let e=0;e<256;++e){i.push((e+256).toString(16).substr(1))}function stringify(e,t=0){const r=(i[e[t+0]]+i[e[t+1]]+i[e[t+2]]+i[e[t+3]]+"-"+i[e[t+4]]+i[e[t+5]]+"-"+i[e[t+6]]+i[e[t+7]]+"-"+i[e[t+8]]+i[e[t+9]]+"-"+i[e[t+10]]+i[e[t+11]]+i[e[t+12]]+i[e[t+13]]+i[e[t+14]]+i[e[t+15]]).toLowerCase();if(!(0,n.default)(r)){throw TypeError("Stringified UUID is invalid")}return r}var o=stringify;t["default"]=o},480:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=_interopRequireDefault(r(584));var i=_interopRequireDefault(r(580));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}let o;let s;let a=0;let u=0;function v1(e,t,r){let c=t&&r||0;const l=t||new Array(16);e=e||{};let d=e.node||o;let f=e.clockseq!==undefined?e.clockseq:s;if(d==null||f==null){const t=e.random||(e.rng||n.default)();if(d==null){d=o=[t[0]|1,t[1],t[2],t[3],t[4],t[5]]}if(f==null){f=s=(t[6]<<8|t[7])&16383}}let p=e.msecs!==undefined?e.msecs:Date.now();let h=e.nsecs!==undefined?e.nsecs:u+1;const m=p-a+(h-u)/1e4;if(m<0&&e.clockseq===undefined){f=f+1&16383}if((m<0||p>a)&&e.nsecs===undefined){h=0}if(h>=1e4){throw new Error("uuid.v1(): Can't create more than 10M uuids/sec")}a=p;u=h;s=f;p+=122192928e5;const v=((p&268435455)*1e4+h)%4294967296;l[c++]=v>>>24&255;l[c++]=v>>>16&255;l[c++]=v>>>8&255;l[c++]=v&255;const _=p/4294967296*1e4&268435455;l[c++]=_>>>8&255;l[c++]=_&255;l[c++]=_>>>24&15|16;l[c++]=_>>>16&255;l[c++]=f>>>8|128;l[c++]=f&255;for(let e=0;e<6;++e){l[c+e]=d[e]}return t||(0,i.default)(l)}var c=v1;t["default"]=c},770:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=_interopRequireDefault(r(771));var i=_interopRequireDefault(r(865));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const o=(0,n.default)("v3",48,i.default);var s=o;t["default"]=s},771:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=_default;t.URL=t.DNS=void 0;var n=_interopRequireDefault(r(580));var i=_interopRequireDefault(r(74));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function stringToBytes(e){e=unescape(encodeURIComponent(e));const t=[];for(let r=0;r{"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=_interopRequireDefault(r(584));var i=_interopRequireDefault(r(580));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function v4(e,t,r){e=e||{};const o=e.random||(e.rng||n.default)();o[6]=o[6]&15|64;o[8]=o[8]&63|128;if(t){r=r||0;for(let e=0;e<16;++e){t[r+e]=o[e]}return t}return(0,i.default)(o)}var o=v4;t["default"]=o},332:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=_interopRequireDefault(r(771));var i=_interopRequireDefault(r(508));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const o=(0,n.default)("v5",80,i.default);var s=o;t["default"]=s},575:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=_interopRequireDefault(r(2));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function validate(e){return typeof e==="string"&&n.default.test(e)}var i=validate;t["default"]=i},957:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=_interopRequireDefault(r(575));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function version(e){if(!(0,n.default)(e)){throw TypeError("Invalid UUID")}return parseInt(e.substr(14,1),16)}var i=version;t["default"]=i},1:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var i=Object.getOwnPropertyDescriptor(t,r);if(!i||("get"in i?!t.__esModule:i.writable||i.configurable)){i={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,i)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.prototype.hasOwnProperty.call(e,r))n(t,e,r);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});t.main=void 0;const a=o(r(167));const u=o(r(471));const c=o(r(921));const l=o(r(857));const d=o(r(928));const f=o(r(982));const p=r(23);const h=p.promisify(r(317).exec);const m=r(719);const v="Starting script execution via docker image mcr.microsoft.com/azure-cli:";const _="agentazcliversion";const g=!!process.env.AZURE_HTTP_USER_AGENT?`${process.env.AZURE_HTTP_USER_AGENT}`:"";const y="https://mcr.microsoft.com/v2/azure-cli/tags/list";function main(){return s(this,void 0,void 0,(function*(){let e=f.createHash("sha256").update(`${process.env.GITHUB_REPOSITORY}`).digest("hex");let t="AzureCLIAction";let r=(!!g?`${g}+`:"")+`GITHUBACTIONS/${t}@v2_${e}_${process.env.RUNNER_ENVIRONMENT}_${process.env.GITHUB_RUN_ID}`;process.env.AZURE_HTTP_USER_AGENT=r;var n="";const i=`MICROSOFT_AZURE_CLI_${(0,m.getCurrentTime)()}_CONTAINER`;try{if(process.env.RUNNER_OS!="Linux"){throw new Error("Please use Linux-based OS as a runner.")}let e=a.getInput("inlineScript",{required:true});let t=a.getInput("azcliversion",{required:false}).trim().toLowerCase();if(t==_){try{const{stdout:e}=yield h("az version");t=JSON.parse(e)["azure-cli"]}catch(e){console.log("Failed to fetch az cli version from agent. Reverting back to latest.");t="latest"}}if(!(yield checkIfValidCLIVersion(t))){a.error("Please enter a valid azure cli version. \nSee available versions: https://github.com/Azure/azure-cli/releases");throw new Error("Please enter a valid azure cli version. \nSee available versions: https://github.com/Azure/azure-cli/releases")}if(!e.trim()){a.error("Please enter a valid script.");throw new Error("Please enter a valid script.")}e=` set -e >&2; echo '${v}' >&2; ${e}`;n=yield(0,m.createScriptFile)(e);const r=process.env.AZURE_CONFIG_DIR||d.join(process.env.HOME,".azure");const o="/root/.azure";let s=["run","--workdir",`${process.env.GITHUB_WORKSPACE}`,"-v",`${process.env.GITHUB_WORKSPACE}:${process.env.GITHUB_WORKSPACE}`,"-v",`${r}:${o}`,"-v",`${m.TEMP_DIRECTORY}:${m.TEMP_DIRECTORY}`];for(let e in process.env){if(!(0,m.checkIfEnvironmentVariableIsOmitted)(e)&&process.env[e]){s.push("-e",`${e}=${process.env[e]}`)}}s.push("--name",i,`mcr.microsoft.com/azure-cli:${t}`,"bash","--noprofile","--norc","-e",`${m.TEMP_DIRECTORY}/${n}`);console.log(`${v}${t}`);yield executeDockerCommand(s);console.log("az script ran successfully.")}catch(e){a.error(e);throw e}finally{const e=d.join(m.TEMP_DIRECTORY,n);yield(0,m.deleteFile)(e);console.log("cleaning up container...");yield executeDockerCommand(["rm","--force",i],true)}}))}t.main=main;const checkIfValidCLIVersion=e=>s(void 0,void 0,void 0,(function*(){const t=yield getAllAzCliVersions();if(!t||t.length==0){return true}return t.some((t=>t.toLowerCase()===e))}));const getAllAzCliVersions=()=>s(void 0,void 0,void 0,(function*(){try{const e=yield fetch(y);if(!e.ok){const t=yield e.text();throw new Error(`HTTP error! status: ${e.status}, errorText: ${t}`)}const t=yield e.json();if(t&&t.tags){return t.tags}else{throw new Error("Response data does not contain tags.")}}catch(e){a.warning(`Unable to fetch all az cli versions with Error: ${e}. Skipping the version check.`)}return[]}));const executeDockerCommand=(e,t=false)=>s(void 0,void 0,void 0,(function*(){const r=yield c.which("docker",true);var n="";var i=false;var o={outStream:new m.NullOutstreamStringWritable({decodeStrings:false}),listeners:{stdout:e=>console.log(e.toString()),errline:e=>{if(!i){n+=e+l.EOL}else{console.log(e)}if(e.trim()===v){i=true;n=""}}}};var s;try{s=yield u.exec(r,e,o)}catch(e){if(!t){throw e}a.warning(e)}finally{if(s!==0&&!t){throw new Error(n||"az cli script failed.")}a.warning(n)}}))},719:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var i=Object.getOwnPropertyDescriptor(t,r);if(!i||("get"in i?!t.__esModule:i.writable||i.configurable)){i={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,i)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.prototype.hasOwnProperty.call(e,r))n(t,e,r);i(t,e);return t};var s=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});t.checkIfEnvironmentVariableIsOmitted=t.NullOutstreamStringWritable=t.getCurrentTime=t.giveExecutablePermissionsToFile=t.deleteFile=t.createScriptFile=t.TEMP_DIRECTORY=void 0;const a=r(203);const u=o(r(471));const c=o(r(167));const l=o(r(928));const d=o(r(857));const f=o(r(896));t.TEMP_DIRECTORY=process.env.RUNNER_TEMP||d.tmpdir();const createScriptFile=e=>s(void 0,void 0,void 0,(function*(){const r=`AZ_CLI_GITHUB_ACTION_${(0,t.getCurrentTime)().toString()}.sh`;const n=l.join(t.TEMP_DIRECTORY,r);f.writeFileSync(n,`${e}`);yield(0,t.giveExecutablePermissionsToFile)(n);return r}));t.createScriptFile=createScriptFile;const deleteFile=e=>s(void 0,void 0,void 0,(function*(){if(f.existsSync(e)){try{f.unlinkSync(e)}catch(e){c.warning(e.toString())}}}));t.deleteFile=deleteFile;const giveExecutablePermissionsToFile=e=>s(void 0,void 0,void 0,(function*(){return yield u.exec("chmod",["+x",e],{silent:true})}));t.giveExecutablePermissionsToFile=giveExecutablePermissionsToFile;const getCurrentTime=()=>(new Date).getTime();t.getCurrentTime=getCurrentTime;class NullOutstreamStringWritable extends a.Writable{constructor(e){super(e)}_write(e,t,r){if(r){r()}}}t.NullOutstreamStringWritable=NullOutstreamStringWritable;const checkIfEnvironmentVariableIsOmitted=e=>{const t=["LANG","HOSTNAME","PWD","HOME","PYTHON_VERSION","PYTHON_PIP_VERSION","SHLVL","PATH","GPG_KEY","CONDA","AGENT_TOOLSDIRECTORY","RUNNER_PERFLOG","RUNNER_WORKSPACE","RUNNER_TEMP","RUNNER_TRACKING_ID","RUNNER_TOOL_CACHE","DOTNET_SKIP_FIRST_TIME_EXPERIENCE","JOURNAL_STREAM","DEPLOYMENT_BASEPATH","VCPKG_INSTALLATION_ROOT","PERFLOG_LOCATION_SETTING","AZURE_CONFIG_DIR"];const r=["JAVA_","LEIN_","M2_","BOOST_","GOROOT","ANDROID_","GRADLE_","ANT_","CHROME","SELENIUM_","INPUT_"];for(let r=0;re.toUpperCase().startsWith(t)))};t.checkIfEnvironmentVariableIsOmitted=checkIfEnvironmentVariableIsOmitted},613:e=>{"use strict";e.exports=require("assert")},317:e=>{"use strict";e.exports=require("child_process")},982:e=>{"use strict";e.exports=require("crypto")},53:e=>{"use strict";e.exports=require("events")},896:e=>{"use strict";e.exports=require("fs")},611:e=>{"use strict";e.exports=require("http")},692:e=>{"use strict";e.exports=require("https")},278:e=>{"use strict";e.exports=require("net")},857:e=>{"use strict";e.exports=require("os")},928:e=>{"use strict";e.exports=require("path")},203:e=>{"use strict";e.exports=require("stream")},756:e=>{"use strict";e.exports=require("tls")},23:e=>{"use strict";e.exports=require("util")}};var t={};function __nccwpck_require__(r){var n=t[r];if(n!==undefined){return n.exports}var i=t[r]={exports:{}};var o=true;try{e[r].call(i.exports,i,i.exports,__nccwpck_require__);o=false}finally{if(o)delete t[r]}return i.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r={};(()=>{"use strict";var e=r;Object.defineProperty(e,"__esModule",{value:true});const t=__nccwpck_require__(167);const n=__nccwpck_require__(1);(0,n.main)().then((()=>{process.exit(0)})).catch((e=>{(0,t.setFailed)(e.message);process.exit(1)}))})();module.exports=r})(); -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cli", 3 | "version": "2.1.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "cli", 9 | "version": "2.1.0", 10 | "license": "MIT", 11 | "dependencies": { 12 | "@actions/core": "^1.10.0", 13 | "@actions/exec": "^1.0.1", 14 | "@actions/io": "^1.0.1", 15 | "@types/node": "^20.11.1" 16 | }, 17 | "devDependencies": { 18 | "@vercel/ncc": "^0.38.1", 19 | "typescript": "^5.3.3" 20 | } 21 | }, 22 | "node_modules/@actions/core": { 23 | "version": "1.10.0", 24 | "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", 25 | "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", 26 | "dependencies": { 27 | "@actions/http-client": "^2.0.1", 28 | "uuid": "^8.3.2" 29 | } 30 | }, 31 | "node_modules/@actions/exec": { 32 | "version": "1.0.1", 33 | "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.1.tgz", 34 | "integrity": "sha512-nvFkxwiicvpzNiCBF4wFBDfnBvi7xp/as7LE1hBxBxKG2L29+gkIPBiLKMVORL+Hg3JNf07AKRfl0V5djoypjQ==" 35 | }, 36 | "node_modules/@actions/http-client": { 37 | "version": "2.0.1", 38 | "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz", 39 | "integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==", 40 | "dependencies": { 41 | "tunnel": "^0.0.6" 42 | } 43 | }, 44 | "node_modules/@actions/io": { 45 | "version": "1.0.1", 46 | "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.1.tgz", 47 | "integrity": "sha512-rhq+tfZukbtaus7xyUtwKfuiCRXd1hWSfmJNEpFgBQJ4woqPEpsBw04awicjwz9tyG2/MVhAEMfVn664Cri5zA==" 48 | }, 49 | "node_modules/@types/node": { 50 | "version": "20.11.19", 51 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.19.tgz", 52 | "integrity": "sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==", 53 | "dependencies": { 54 | "undici-types": "~5.26.4" 55 | } 56 | }, 57 | "node_modules/@vercel/ncc": { 58 | "version": "0.38.1", 59 | "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.1.tgz", 60 | "integrity": "sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==", 61 | "dev": true, 62 | "bin": { 63 | "ncc": "dist/ncc/cli.js" 64 | } 65 | }, 66 | "node_modules/tunnel": { 67 | "version": "0.0.6", 68 | "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", 69 | "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", 70 | "engines": { 71 | "node": ">=0.6.11 <=0.7.0 || >=0.7.3" 72 | } 73 | }, 74 | "node_modules/typescript": { 75 | "version": "5.3.3", 76 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", 77 | "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", 78 | "dev": true, 79 | "bin": { 80 | "tsc": "bin/tsc", 81 | "tsserver": "bin/tsserver" 82 | }, 83 | "engines": { 84 | "node": ">=14.17" 85 | } 86 | }, 87 | "node_modules/undici-types": { 88 | "version": "5.26.5", 89 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 90 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" 91 | }, 92 | "node_modules/uuid": { 93 | "version": "8.3.2", 94 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", 95 | "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", 96 | "bin": { 97 | "uuid": "dist/bin/uuid" 98 | } 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cli", 3 | "version": "2.1.0", 4 | "description": "Automate your GitHub workflows using Azure CLI scripts.", 5 | "main": "src/main.js", 6 | "scripts": { 7 | "build": "ncc build -C -m src/entrypoint.ts", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/Azure/CLI.git" 13 | }, 14 | "author": "Microsoft", 15 | "license": "MIT", 16 | "devDependencies": { 17 | "@vercel/ncc": "^0.38.1", 18 | "typescript": "^5.3.3" 19 | }, 20 | "dependencies": { 21 | "@actions/core": "^1.10.0", 22 | "@actions/exec": "^1.0.1", 23 | "@actions/io": "^1.0.1", 24 | "@types/node": "^20.11.1" 25 | }, 26 | "bugs": { 27 | "url": "https://github.com/Azure/CLI/issues" 28 | }, 29 | "homepage": "https://github.com/Azure/CLI#readme" 30 | } 31 | -------------------------------------------------------------------------------- /src/entrypoint.ts: -------------------------------------------------------------------------------- 1 | import { setFailed } from '@actions/core'; 2 | import { main } from './main'; 3 | 4 | main() 5 | .then(() => { 6 | process.exit(0) 7 | }) 8 | .catch((err: Error) => { 9 | setFailed(err.message); 10 | process.exit(1); 11 | }); -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core'; 2 | import * as exec from '@actions/exec'; 3 | import * as io from '@actions/io'; 4 | import * as os from 'os'; 5 | import * as path from 'path'; 6 | import * as crypto from 'crypto'; 7 | const util = require('util'); 8 | const cpExec = util.promisify(require('child_process').exec); 9 | 10 | import { createScriptFile, TEMP_DIRECTORY, NullOutstreamStringWritable, deleteFile, getCurrentTime, checkIfEnvironmentVariableIsOmitted } from './utils'; 11 | 12 | const START_SCRIPT_EXECUTION_MARKER: string = "Starting script execution via docker image mcr.microsoft.com/azure-cli:"; 13 | const AZ_CLI_VERSION_DEFAULT_VALUE = 'agentazcliversion' 14 | const prefix = !!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT}` : ""; 15 | const AZ_CLI_TAG_lIST_URL = "https://mcr.microsoft.com/v2/azure-cli/tags/list"; 16 | 17 | export async function main() { 18 | let usrAgentRepo = crypto.createHash('sha256').update(`${process.env.GITHUB_REPOSITORY}`).digest('hex'); 19 | let actionName = 'AzureCLIAction'; 20 | let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS/${actionName}@v2_${usrAgentRepo}_${process.env.RUNNER_ENVIRONMENT}_${process.env.GITHUB_RUN_ID}`; 21 | process.env.AZURE_HTTP_USER_AGENT = userAgentString; 22 | 23 | var scriptFileName: string = ''; 24 | const CONTAINER_NAME = `MICROSOFT_AZURE_CLI_${getCurrentTime()}_CONTAINER`; 25 | try { 26 | if (process.env.RUNNER_OS != 'Linux') { 27 | throw new Error('Please use Linux-based OS as a runner.'); 28 | } 29 | 30 | let inlineScript: string = core.getInput('inlineScript', { required: true }); 31 | let azcliversion: string = core.getInput('azcliversion', { required: false }).trim().toLowerCase(); 32 | 33 | if (azcliversion == AZ_CLI_VERSION_DEFAULT_VALUE) { 34 | try { 35 | const { stdout } = await cpExec('az version'); 36 | azcliversion = JSON.parse(stdout)["azure-cli"] 37 | } catch (err) { 38 | console.log('Failed to fetch az cli version from agent. Reverting back to latest.') 39 | azcliversion = 'latest' 40 | } 41 | } 42 | 43 | if (!(await checkIfValidCLIVersion(azcliversion))) { 44 | core.error('Please enter a valid azure cli version. \nSee available versions: https://github.com/Azure/azure-cli/releases'); 45 | throw new Error('Please enter a valid azure cli version. \nSee available versions: https://github.com/Azure/azure-cli/releases') 46 | } 47 | 48 | if (!inlineScript.trim()) { 49 | core.error('Please enter a valid script.'); 50 | throw new Error('Please enter a valid script.') 51 | } 52 | inlineScript = ` set -e >&2; echo '${START_SCRIPT_EXECUTION_MARKER}' >&2; ${inlineScript}`; 53 | scriptFileName = await createScriptFile(inlineScript); 54 | 55 | const hostAzureConfigDir = process.env.AZURE_CONFIG_DIR || path.join(process.env.HOME, '.azure'); 56 | const containerAzureConfigDir = '/root/.azure'; 57 | 58 | /* 59 | For the docker run command, we are doing the following 60 | - Set the working directory for docker continer 61 | - volume mount the GITHUB_WORKSPACE env variable (path where users checkout code is present) to work directory of container 62 | - volume mount Azure config directory between host and container, 63 | - volume mount temp directory between host and container, inline script file is created in temp directory 64 | */ 65 | let args: string[] = ["run", "--workdir", `${process.env.GITHUB_WORKSPACE}`, 66 | "-v", `${process.env.GITHUB_WORKSPACE}:${process.env.GITHUB_WORKSPACE}`, 67 | "-v", `${hostAzureConfigDir}:${containerAzureConfigDir}`, 68 | "-v", `${TEMP_DIRECTORY}:${TEMP_DIRECTORY}` 69 | ]; 70 | for (let key in process.env) { 71 | if (!checkIfEnvironmentVariableIsOmitted(key) && process.env[key]) { 72 | args.push("-e", `${key}=${process.env[key]}`); 73 | } 74 | } 75 | args.push("--name", CONTAINER_NAME, 76 | `mcr.microsoft.com/azure-cli:${azcliversion}`, 77 | "bash", "--noprofile", "--norc", "-e", `${TEMP_DIRECTORY}/${scriptFileName}`); 78 | 79 | console.log(`${START_SCRIPT_EXECUTION_MARKER}${azcliversion}`); 80 | await executeDockerCommand(args); 81 | console.log("az script ran successfully."); 82 | } 83 | catch (error) { 84 | core.error(error); 85 | throw error; 86 | } 87 | finally { 88 | // clean up 89 | const scriptFilePath: string = path.join(TEMP_DIRECTORY, scriptFileName); 90 | await deleteFile(scriptFilePath); 91 | console.log("cleaning up container..."); 92 | await executeDockerCommand(["rm", "--force", CONTAINER_NAME], true); 93 | } 94 | }; 95 | 96 | const checkIfValidCLIVersion = async (azcliversion: string): Promise => { 97 | const allVersions: Array = await getAllAzCliVersions(); 98 | if (!allVersions || allVersions.length == 0) { 99 | return true; 100 | } 101 | return allVersions.some((eachVersion) => eachVersion.toLowerCase() === azcliversion); 102 | } 103 | 104 | const getAllAzCliVersions = async (): Promise> => { 105 | try { 106 | const response = await fetch(AZ_CLI_TAG_lIST_URL); 107 | if (!response.ok) { 108 | const errorText = await response.text(); 109 | throw new Error(`HTTP error! status: ${response.status}, errorText: ${errorText}`); 110 | } 111 | const data = await response.json(); 112 | if (data && data.tags) { 113 | return data.tags; 114 | } 115 | else { 116 | throw new Error('Response data does not contain tags.'); 117 | } 118 | } 119 | catch (error) { 120 | core.warning(`Unable to fetch all az cli versions with Error: ${error}. Skipping the version check.`); 121 | } 122 | return []; 123 | }; 124 | 125 | const executeDockerCommand = async (args: string[], continueOnError: boolean = false): Promise => { 126 | const dockerTool: string = await io.which("docker", true); 127 | var errorStream: string = ''; 128 | var shouldOutputErrorStream: boolean = false; 129 | var execOptions: any = { 130 | outStream: new NullOutstreamStringWritable({ decodeStrings: false }), 131 | listeners: { 132 | stdout: (data: any) => console.log(data.toString()), //to log the script output while the script is running. 133 | errline: (data: string) => { 134 | if (!shouldOutputErrorStream) { 135 | errorStream += data + os.EOL; 136 | } 137 | else { 138 | console.log(data); 139 | } 140 | if (data.trim() === START_SCRIPT_EXECUTION_MARKER) { 141 | shouldOutputErrorStream = true; 142 | errorStream = ''; // Flush the container logs. After this, script error logs will be tracked. 143 | } 144 | } 145 | } 146 | }; 147 | var exitCode; 148 | try { 149 | exitCode = await exec.exec(dockerTool, args, execOptions); 150 | } catch (error) { 151 | if (!continueOnError) { 152 | throw error; 153 | } 154 | core.warning(error); 155 | } 156 | finally { 157 | if (exitCode !== 0 && !continueOnError) { 158 | throw new Error(errorStream || 'az cli script failed.'); 159 | } 160 | core.warning(errorStream) 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | import stream = require('stream'); 2 | import * as exec from '@actions/exec'; 3 | import * as core from '@actions/core'; 4 | import * as path from 'path'; 5 | import * as os from 'os'; 6 | import * as fs from 'fs'; 7 | 8 | export const TEMP_DIRECTORY: string = process.env.RUNNER_TEMP || os.tmpdir(); 9 | 10 | export const createScriptFile = async (inlineScript: string): Promise => { 11 | const fileName: string = `AZ_CLI_GITHUB_ACTION_${getCurrentTime().toString()}.sh`; 12 | const filePath: string = path.join(TEMP_DIRECTORY, fileName); 13 | fs.writeFileSync(filePath, `${inlineScript}`); 14 | await giveExecutablePermissionsToFile(filePath); 15 | return fileName; 16 | } 17 | 18 | 19 | export const deleteFile = async (filePath: string) => { 20 | if (fs.existsSync(filePath)) { 21 | try { 22 | fs.unlinkSync(filePath); 23 | } 24 | catch (err) { 25 | core.warning(err.toString()); 26 | } 27 | } 28 | } 29 | 30 | export const giveExecutablePermissionsToFile = async (filePath: string): Promise => await exec.exec('chmod', ['+x', filePath], { silent: true }) 31 | 32 | export const getCurrentTime = (): number => { 33 | return new Date().getTime(); 34 | } 35 | 36 | export class NullOutstreamStringWritable extends stream.Writable { 37 | 38 | constructor(options: any) { 39 | super(options); 40 | } 41 | 42 | _write(data: any, encoding: string, callback: Function): void { 43 | if (callback) { 44 | callback(); 45 | } 46 | } 47 | }; 48 | 49 | export const checkIfEnvironmentVariableIsOmitted = (key: string): boolean => { 50 | 51 | const omitEnvironmentVariables: string [] = [ 52 | 'LANG', 53 | 'HOSTNAME', 54 | 'PWD', 55 | 'HOME', 56 | 'PYTHON_VERSION', 57 | 'PYTHON_PIP_VERSION', 58 | 'SHLVL', 59 | 'PATH', 60 | 'GPG_KEY', 61 | 'CONDA', 62 | 'AGENT_TOOLSDIRECTORY', 63 | 'RUNNER_PERFLOG', 64 | 'RUNNER_WORKSPACE', 65 | 'RUNNER_TEMP', 66 | 'RUNNER_TRACKING_ID', 67 | 'RUNNER_TOOL_CACHE', 68 | 'DOTNET_SKIP_FIRST_TIME_EXPERIENCE', 69 | 'JOURNAL_STREAM', 70 | 'DEPLOYMENT_BASEPATH', 71 | 'VCPKG_INSTALLATION_ROOT', 72 | 'PERFLOG_LOCATION_SETTING', 73 | 'AZURE_CONFIG_DIR' 74 | ]; 75 | 76 | const omitEnvironmentVariablesWithPrefix: string [] = [ 77 | 'JAVA_', 78 | 'LEIN_', 79 | 'M2_', 80 | 'BOOST_', 81 | 'GOROOT', 82 | 'ANDROID_', 83 | 'GRADLE_', 84 | 'ANT_', 85 | 'CHROME', 86 | 'SELENIUM_', 87 | 'INPUT_' 88 | ]; 89 | for (let i = 0; i < omitEnvironmentVariables.length; i++){ 90 | if (omitEnvironmentVariables[i] === key.toUpperCase()){ 91 | return true; 92 | } 93 | } 94 | 95 | return omitEnvironmentVariablesWithPrefix.some((prefix: string) => key.toUpperCase().startsWith(prefix)); 96 | } 97 | -------------------------------------------------------------------------------- /test/main.test.ts: -------------------------------------------------------------------------------- 1 | import { main } from "../src/main"; 2 | import * as core from '@actions/core'; 3 | 4 | // Unit Tests 5 | export async function runTests() { 6 | try { 7 | await main() 8 | return 'pass' 9 | } catch (e) { 10 | core.error(JSON.stringify(e)) 11 | return 'fail' 12 | } 13 | } 14 | 15 | runTests().then(outcome => { 16 | if(outcome != process.env.EXPECTED_TO){ 17 | core.error(`Expected outcome did not meet the real outcome. Expected value: ${process.env.EXPECTED_TO}, actual value: ${outcome}`) 18 | process.exit(1) 19 | } 20 | }) 21 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Basic Options */ 4 | // "incremental": true, /* Enable incremental compilation */ 5 | "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 6 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 7 | "sourceMap": true, 8 | // "lib": [], /* Specify library files to be included in the compilation. */ 9 | // "allowJs": true, /* Allow javascript files to be compiled. */ 10 | // "checkJs": true, /* Report errors in .js files. */ 11 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 12 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 13 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 14 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 15 | // "outFile": "./", /* Concatenate and emit output to single file. */ 16 | // "outDir": "./", /* Redirect output structure to the directory. */ 17 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 18 | // "composite": true, /* Enable project compilation */ 19 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 20 | // "removeComments": true, /* Do not emit comments to output. */ 21 | // "noEmit": true, /* Do not emit outputs. */ 22 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 23 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 24 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 25 | /* Strict Type-Checking Options */ 26 | "strict": false, /* Enable all strict type-checking options. */ 27 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 28 | // "strictNullChecks": true, /* Enable strict null checks. */ 29 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 30 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 31 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 32 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 33 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 34 | /* Additional Checks */ 35 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 36 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 37 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 38 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 39 | /* Module Resolution Options */ 40 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 41 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 42 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 43 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 44 | // "typeRoots": [], /* List of folders to include type definitions from. */ 45 | // "types": [], /* Type declaration files to be included in compilation. */ 46 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 47 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 48 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 49 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 50 | /* Source Map Options */ 51 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 52 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 53 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 54 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 55 | /* Experimental Options */ 56 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 57 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 58 | /* Advanced Options */ 59 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 60 | } 61 | } --------------------------------------------------------------------------------