{"id":56535,"date":"2025-02-22T08:20:44","date_gmt":"2025-02-22T00:20:44","guid":{"rendered":"https:\/\/fwq.ai\/blog\/56535\/"},"modified":"2025-02-22T08:20:44","modified_gmt":"2025-02-22T00:20:44","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8github%e4%b8%8a%e4%bd%bf%e7%94%a8vultr%e8%bf%9b%e8%a1%8c%e8%b5%84%e6%ba%90%e9%94%80%e6%af%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/56535\/","title":{"rendered":"\u5982\u4f55\u5728GitHub\u4e0a\u4f7f\u7528Vultr\u8fdb\u884c\u8d44\u6e90\u9500\u6bc1"},"content":{"rendered":"<h2>\u5f15\u8a00<\/h2>\n<p>\u5728\u4e91\u8ba1\u7b97\u5feb\u901f\u53d1\u5c55\u7684\u4eca\u5929\uff0c\u8bb8\u591a\u5f00\u53d1\u8005\u548c\u8fd0\u7ef4\u5de5\u7a0b\u5e08\u4f9d\u8d56\u4e8e\u4e91\u670d\u52a1\u63d0\u4f9b\u5546\u5982Vultr\u6765\u7ba1\u7406\u548c\u90e8\u7f72\u4ed6\u4eec\u7684\u5e94\u7528\u3002\u7136\u800c\uff0c\u968f\u7740\u9879\u76ee\u7684\u8fdb\u5c55\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0\u9700\u8981<strong>\u9500\u6bc1<\/strong>\u4e0d\u518d\u4f7f\u7528\u7684\u4e91\u8d44\u6e90\u7684\u60c5\u51b5\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7GitHub\u548cVultr\u5b9e\u73b0\u8d44\u6e90\u7684\u9500\u6bc1\uff0c\u5e76\u89e3\u7b54\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u3002<\/p>\n<h2>\u4e3a\u4ec0\u4e48\u9009\u62e9Vultr\u8fdb\u884c\u8d44\u6e90\u9500\u6bc1<\/h2>\n<ul>\n<li><strong>\u6613\u4e8e\u4f7f\u7528<\/strong>\uff1aVultr\u7684\u63a7\u5236\u9762\u677f\u76f4\u89c2\uff0c\u4fbf\u4e8e\u7528\u6237\u7ba1\u7406\u4e91\u8d44\u6e90\u3002<\/li>\n<li><strong>API\u652f\u6301<\/strong>\uff1aVultr\u63d0\u4f9b\u5f3a\u5927\u7684API\uff0c\u53ef\u4ee5\u4e0eGitHub\u7b49\u5de5\u5177\u96c6\u6210\u3002<\/li>\n<li><strong>\u5feb\u901f\u90e8\u7f72<\/strong>\uff1aVultr\u80fd\u591f\u8fc5\u901f\u521b\u5efa\u548c\u9500\u6bc1\u4e91\u670d\u52a1\u5668\uff0c\u7075\u6d3b\u5e94\u5bf9\u5f00\u53d1\u9700\u6c42\u3002<\/li>\n<\/ul>\n<h2>GitHub\u4e0eVultr\u7684\u96c6\u6210<\/h2>\n<p>\u5728\u8fdb\u884c\u8d44\u6e90\u9500\u6bc1\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5c06GitHub\u4e0eVultr\u96c6\u6210\u3002<\/p>\n<h3>1. \u83b7\u53d6Vultr API\u5bc6\u94a5<\/h3>\n<ul>\n<li>\u767b\u5f55\u5230Vultr\u8d26\u6237\u3002<\/li>\n<li>\u8fdb\u5165\u201cAPI\u201d\u9875\u9762\uff0c\u751f\u6210\u4e00\u4e2a\u65b0\u7684API\u5bc6\u94a5\u3002<\/li>\n<li>\u8bb0\u5f55\u4e0b\u8be5\u5bc6\u94a5\uff0c\u540e\u7eed\u9700\u8981\u7528\u5230\u3002<\/li>\n<\/ul>\n<h3>2. \u521b\u5efaGitHub\u4ed3\u5e93<\/h3>\n<ul>\n<li>\u767b\u5f55GitHub\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u4ed3\u5e93\u4ee5\u7ba1\u7406\u4f60\u7684\u81ea\u52a8\u5316\u811a\u672c\u3002<\/li>\n<li>\u5728\u4ed3\u5e93\u4e2d\u6dfb\u52a0\u76f8\u5173\u6587\u4ef6\uff0c\u5982<code>destroy.js<\/code>\u3002<\/li>\n<\/ul>\n<h3>3. \u914d\u7f6eGitHub Actions<\/h3>\n<ul>\n<li>\u5728GitHub\u4ed3\u5e93\u4e2d\u914d\u7f6eActions\uff0c\u4f7f\u7528YAML\u6587\u4ef6\u5b9a\u4e49\u5de5\u4f5c\u6d41\u3002<\/li>\n<li>\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u4f5c\u4e3a\u53c2\u8003\uff1a yaml name: Destroy Vultr Resources on: push: branches: \u2013 main jobs: destroy: runs-on: ubuntu-latest steps: \u2013 name: Checkout code uses: actions\/checkout@v2 \u2013 name: Install Node.js uses: actions\/setup-node@v2 with: node-version: \u201914\u2019 \u2013 name: Run destruction script env: VULTR_API_KEY: ${{ secrets.VULTR_API_KEY }} run: | node destroy.js<\/li>\n<\/ul>\n<h2>\u4f7f\u7528Node.js\u7f16\u5199\u8d44\u6e90\u9500\u6bc1\u811a\u672c<\/h2>\n<h3>1. \u5b89\u88c5\u5fc5\u8981\u7684\u4f9d\u8d56<\/h3>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Vultr API\u5ba2\u6237\u7aef\uff1a bash npm install vultr-api<\/p>\n<h3>2. \u7f16\u5199\u9500\u6bc1\u811a\u672c<\/h3>\n<p>\u5728<code>destroy.js<\/code>\u4e2d\u7f16\u5199\u9500\u6bc1\u903b\u8f91\uff0c\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a javascript const Vultr = require(\u2018vultr-api\u2019);<\/p>\n<p>const vultr = new Vultr({ apiKey: process.env.VULTR_API_KEY });<\/p>\n<p>async function destroyInstance(instanceId) { try { await vultr.instances.destroy(instanceId); console.log(<code>Instance ${instanceId} destroyed successfully.<\/code>); } catch (error) { console.error(\u2018Error destroying instance:\u2019, error); }} destroyInstance(\u2018YOUR_INSTANCE_ID\u2019);<\/p>\n<h3>3. \u89e6\u53d1\u9500\u6bc1\u64cd\u4f5c<\/h3>\n<ul>\n<li>\u5f53\u4ee3\u7801\u63a8\u9001\u5230\u4e3b\u5206\u652f\u65f6\uff0cGitHub Actions\u4f1a\u81ea\u52a8\u8fd0\u884c\uff0c\u5e76\u8c03\u7528\u9500\u6bc1\u811a\u672c\u3002<\/li>\n<li>\u786e\u4fdd\u5c06<code>YOUR_INSTANCE_ID<\/code>\u66ff\u6362\u4e3a\u4f60\u8981\u9500\u6bc1\u7684\u5b9e\u4f8bID\u3002<\/li>\n<\/ul>\n<h2>\u5e38\u89c1\u95ee\u9898\u89e3\u7b54 (FAQ)<\/h2>\n<h3>Q1: \u5982\u4f55\u67e5\u770b\u6211\u7684Vultr\u5b9e\u4f8bID\uff1f<\/h3>\n<p>A: \u767b\u5f55\u5230Vultr\u63a7\u5236\u9762\u677f\uff0c\u6240\u6709\u5b9e\u4f8b\u7684ID\u4f1a\u5728\u201c\u5b9e\u4f8b\u201d\u9875\u9762\u663e\u793a\u3002<\/p>\n<h3>Q2: \u5982\u679c\u9500\u6bc1\u540e\u9700\u8981\u6062\u590d\u6570\u636e\uff0c\u5e94\u8be5\u600e\u4e48\u505a\uff1f<\/h3>\n<p>A: \u5728\u9500\u6bc1\u5b9e\u4f8b\u4e4b\u524d\uff0c\u786e\u4fdd\u4f60\u5df2\u5907\u4efd\u4e86\u6240\u6709\u91cd\u8981\u6570\u636e\u3002<\/p>\n<h3>Q3: Vultr\u7684\u9500\u6bc1\u64cd\u4f5c\u662f\u5426\u7acb\u5373\u751f\u6548\uff1f<\/h3>\n<p>A: \u662f\u7684\uff0cVultr\u7684\u9500\u6bc1\u64cd\u4f5c\u4f1a\u7acb\u5373\u751f\u6548\uff0c\u4f46\u6709\u65f6\u53ef\u80fd\u9700\u8981\u51e0\u5206\u949f\u65f6\u95f4\u624d\u80fd\u5b8c\u5168\u79fb\u9664\u8d44\u6e90\u3002<\/p>\n<h3>Q4: \u4f7f\u7528GitHub Actions\u6267\u884c\u9500\u6bc1\u64cd\u4f5c\u4f1a\u4ea7\u751f\u8d39\u7528\u5417\uff1f<\/h3>\n<p>A: GitHub Actions\u7684\u6267\u884c\u662f\u514d\u8d39\u7684\uff0c\u4f46\u4f7f\u7528Vultr\u8d44\u6e90\u65f6\u4f1a\u6309\u6b63\u5e38\u7684\u8ba1\u8d39\u6807\u51c6\u6536\u8d39\u3002<\/p>\n<h3>Q5: \u662f\u5426\u53ef\u4ee5\u6279\u91cf\u9500\u6bc1\u591a\u4e2aVultr\u5b9e\u4f8b\uff1f<\/h3>\n<p>A: \u662f\u7684\uff0c\u53ef\u4ee5\u5728<code>destroy.js<\/code>\u811a\u672c\u4e2d\u5b9e\u73b0\u6279\u91cf\u9500\u6bc1\u903b\u8f91\uff0c\u904d\u5386\u5b9e\u4f8bID\u5e76\u4f9d\u6b21\u8c03\u7528\u9500\u6bc1\u65b9\u6cd5\u3002<\/p>\n<h2>\u6700\u4f73\u5b9e\u8df5<\/h2>\n<ul>\n<li><strong>\u5b9a\u671f\u5ba1\u67e5\u4e91\u8d44\u6e90<\/strong>\uff1a\u5b9a\u671f\u68c0\u67e5\u4e0d\u518d\u4f7f\u7528\u7684\u5b9e\u4f8b\uff0c\u53ca\u65f6\u9500\u6bc1\uff0c\u8282\u7ea6\u8d39\u7528\u3002<\/li>\n<li><strong>\u81ea\u52a8\u5316\u7ba1\u7406<\/strong>\uff1a\u901a\u8fc7GitHub Actions\u7b49\u5de5\u5177\u81ea\u52a8\u5316\u7ba1\u7406\u4e91\u8d44\u6e90\uff0c\u63d0\u9ad8\u6548\u7387\u3002<\/li>\n<li><strong>\u786e\u4fdd\u6570\u636e\u5b89\u5168<\/strong>\uff1a\u5728\u9500\u6bc1\u5b9e\u4f8b\u524d\u5907\u4efd\u91cd\u8981\u6570\u636e\uff0c\u9632\u6b62\u6570\u636e\u4e22\u5931\u3002<\/li>\n<\/ul>\n<h2>\u7ed3\u8bba<\/h2>\n<p>\u5728GitHub\u4e0a\u4f7f\u7528Vultr\u8fdb\u884c\u8d44\u6e90\u9500\u6bc1\u662f\u4e00\u79cd\u9ad8\u6548\u4e14\u7075\u6d3b\u7684\u65b9\u6cd5\u3002\u901a\u8fc7API\u96c6\u6210\u548c\u81ea\u52a8\u5316\u811a\u672c\uff0c\u7528\u6237\u53ef\u4ee5\u8f7b\u677e\u7ba1\u7406\u548c\u9500\u6bc1\u4e0d\u518d\u9700\u8981\u7684\u4e91\u8d44\u6e90\uff0c\u4ece\u800c\u8282\u7701\u6210\u672c\u5e76\u4f18\u5316\u8d44\u6e90\u914d\u7f6e\u3002\u5e0c\u671b\u672c\u6587\u80fd\u4e3a\u60a8\u63d0\u4f9b\u6709\u4ef7\u503c\u7684\u6307\u5bfc\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u8a00 \u5728\u4e91\u8ba1\u7b97\u5feb\u901f\u53d1\u5c55\u7684\u4eca\u5929\uff0c\u8bb8\u591a\u5f00\u53d1\u8005\u548c\u8fd0\u7ef4\u5de5\u7a0b\u5e08\u4f9d\u8d56\u4e8e\u4e91\u670d\u52a1\u63d0\u4f9b\u5546\u5982Vultr\u6765\u7ba1\u7406\u548c\u90e8\u7f72\u4ed6\u4eec\u7684\u5e94\u7528\u3002\u7136\u800c\uff0c\u968f\u7740\u9879\u76ee\u7684\u8fdb\u5c55\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0\u9700\u8981\u9500\u6bc1\u4e0d\u518d\u4f7f\u7528\u7684\u4e91\u8d44\u6e90\u7684\u60c5\u51b5\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7GitHub\u548cVultr\u5b9e\u73b0\u8d44\u6e90\u7684\u9500\u6bc1\uff0c\u5e76\u89e3\u7b54\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u3002 \u4e3a\u4ec0\u4e48\u9009\u62e9Vultr\u8fdb\u884c\u8d44\u6e90\u9500\u6bc1 \u6613\u4e8e\u4f7f\u7528\uff1aVultr\u7684\u63a7\u5236\u9762\u677f\u76f4\u89c2\uff0c\u4fbf\u4e8e\u7528\u6237\u7ba1\u7406\u4e91\u8d44\u6e90\u3002 API\u652f\u6301\uff1aVultr\u63d0\u4f9b\u5f3a\u5927\u7684API\uff0c\u53ef\u4ee5\u4e0eGitHub\u7b49\u5de5\u5177\u96c6\u6210\u3002 \u5feb\u901f\u90e8\u7f72\uff1aVultr\u80fd\u591f\u8fc5\u901f\u521b\u5efa\u548c\u9500\u6bc1\u4e91\u670d\u52a1\u5668\uff0c\u7075\u6d3b\u5e94\u5bf9\u5f00\u53d1\u9700\u6c42\u3002 GitHub\u4e0eVultr\u7684\u96c6\u6210 \u5728\u8fdb\u884c\u8d44\u6e90\u9500\u6bc1\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5c06GitHub\u4e0eVultr\u96c6\u6210\u3002 1. \u83b7\u53d6Vultr API\u5bc6\u94a5 \u767b\u5f55\u5230Vultr\u8d26\u6237\u3002 \u8fdb\u5165\u201cAPI\u201d\u9875\u9762\uff0c\u751f\u6210\u4e00\u4e2a\u65b0\u7684API\u5bc6\u94a5\u3002 \u8bb0\u5f55\u4e0b\u8be5\u5bc6\u94a5\uff0c\u540e\u7eed\u9700\u8981\u7528\u5230\u3002 2. \u521b\u5efaGitHub\u4ed3\u5e93 \u767b\u5f55GitHub\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u4ed3\u5e93\u4ee5\u7ba1\u7406\u4f60\u7684\u81ea\u52a8\u5316\u811a\u672c\u3002 \u5728\u4ed3\u5e93\u4e2d\u6dfb\u52a0\u76f8\u5173\u6587\u4ef6\uff0c\u5982destroy.js\u3002 3. \u914d\u7f6eGitHub Actions \u5728GitHub\u4ed3\u5e93\u4e2d\u914d\u7f6eActions\uff0c\u4f7f\u7528YAML\u6587\u4ef6\u5b9a\u4e49\u5de5\u4f5c\u6d41\u3002 \u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u4f5c\u4e3a\u53c2\u8003\uff1a yaml name: Destroy Vultr Resources on: push: branches: \u2013 main jobs: destroy: runs-on: ubuntu-latest steps: \u2013 name: Checkout code uses: actions\/checkout@v2 \u2013 name: Install Node.js uses: actions\/setup-node@v2 with: node-version: \u201914\u2019 \u2013 name: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-56535","post","type-post","status-publish","format-standard","hentry","category-vpn"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/56535","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=56535"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/56535\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=56535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=56535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=56535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}