Skip to content

Add private registry URLs as output to the start-proxy Action #2652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/__start-proxy.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions lib/start-proxy-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/start-proxy-action.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pr-checks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
env
25 changes: 25 additions & 0 deletions pr-checks/checks/start-proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Start proxy"
description: "Tests that the proxy can be initialised on all platforms"
operatingSystems: ["ubuntu", "macos", "windows"]
versions: ["linked"]
steps:
- uses: ./../action/init
with:
languages: csharp
tools: ${{ steps.prepare-test.outputs.tools-url }}

- name: Setup proxy for registries
id: proxy
uses: ./../action/start-proxy
with:
registry_secrets: '[{ "type": "nuget_feed", "url": "https://api.nuget.org/v3/index.json" }]'

- name: Print proxy outputs
run: |
echo "${{ steps.proxy.outputs.proxy_host }}"
echo "${{ steps.proxy.outputs.proxy_port }}"
echo "${{ steps.proxy.outputs.proxy_urls }}"

- name: Fail if proxy outputs are not set
if: (!steps.proxy.outputs.proxy_host) || (!steps.proxy.outputs.proxy_port) || (!steps.proxy.outputs.proxy_ca_certificate) || (!steps.proxy.outputs.proxy_urls)
run: exit 1
5 changes: 5 additions & 0 deletions src/start-proxy-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ async function startProxy(
core.setOutput("proxy_host", host);
core.setOutput("proxy_port", port.toString());
core.setOutput("proxy_ca_certificate", config.ca.cert);

const registry_urls = config.all_credentials
.filter((credential) => credential.url !== undefined)
Copy link
Preview

Copilot AI Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filter condition should use 'credential.url != null' instead of 'credential.url !== undefined' to properly filter out both 'undefined' and 'null' values.

Suggested change
.filter((credential) => credential.url !== undefined)
.filter((credential) => credential.url != null)

Copilot uses AI. Check for mistakes.

.map((credential) => credential.url);
core.setOutput("proxy_urls", JSON.stringify(registry_urls));
} catch (error) {
core.setFailed(`start-proxy action failed: ${util.getErrorMessage(error)}`);
}
Expand Down
2 changes: 2 additions & 0 deletions start-proxy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ outputs:
description: The port of the proxy
proxy_ca_certificate:
description: The proxy's internal CA certificate in PEM format
proxy_urls:
description: The URLs of the configured registries, as a JSON array.
runs:
using: node20
main: "../lib/start-proxy-action.js"
Expand Down
Loading