如何在Windows服务器防火墙中将GitHub Action的IP地址列入白名单

huangapple go评论87阅读模式
英文:

How to whitelist GitHub Action IPs in windows server firewall

问题

我有Windows Server 2012。我已设置GitLab CI/CD以自动构建并上传构建到服务器。我使用appleboy/scp-action@master GitHub操作来复制文件。它有效!我使用用户名/密钥身份验证,并希望为SSH添加Windows防火墙规则。

是否可以创建防火墙入站规则,允许GitHub Actions的所有IP?如果我理解正确,它们都列在此处

英文:

I have windows server 2012. I did setup gitlab CI/CD to automatically build and upload build to server. I do copy files with appleboy/scp-action@master GitHub Action. It works! I do have username/key authentication and would like to add windows firewall rules for ssh.

Is this possible to make firewall inbound rule for all IPs of GitHub Actions. If I understand correctly, they are all listed in here.

答案1

得分: 1

我不确定你是否真的需要这样做(对于https://api.github.com/meta列出的所有IP),但如果你需要的话,这将是一个PowerShell脚本(确保以管理员身份运行):

``` powershell
$ips = @()
$response = Invoke-RestMethod -Uri https://api.github.com/meta
$ips += $response.actions
Get-NetFirewallrule -DisplayName 'WEB-Inbound'|Set-NetFirewallRule -RemoteAddress $ips

$ips中添加你从meta需要的JSON部分('web'、'packages'、'pages',...)


<details>
<summary>英文:</summary>

I do not know if you actually need to do that (for *all* IPs listed at https://api.github.com/meta), but if you do, that would be a powershell script (surely run as admin) with:

``` powershell
$ips = @()
$response = Invoke-RestMethod -Uri https://api.github.com/meta
$ips += $response.actions
Get-NetFirewallrule -DisplayName &#39;WEB-Inbound&#39;|Set-NetFirewallRule -RemoteAddress $ips

Add in $ips the JSON section you need from meta ('web', 'packages', 'pages', ...)

huangapple
  • 本文由 发表于 2023年3月8日 17:26:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/75671305.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定