分享一次我github被封的经历以及迁移指南

这篇具有很好参考价值的文章主要介绍了分享一次我github被封的经历以及迁移指南。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

点击在线阅读,体验更好 链接
现代JavaScript高级小册 链接
深入浅出Dart 链接
现代TypeScript高级小册 链接
linwu的算法笔记📒 链接

前言

上星期四,我像往常一样起床上班,地铁上收到了微信消息

分享一次我github被封的经历以及迁移指南,github,网络协议,网络,go,前端,ssl,原力计划

这时候就感觉到不对劲了,到了公司我登录了自己的github,发现被封了

分享一次我github被封的经历以及迁移指南,github,网络协议,网络,go,前端,ssl,原力计划

毫无征兆,我的gmail也没有收到github邮箱。

因为这个github账号我一直用来存放我的网站资料以及blog,所以很多issue都在里面,另外还有部分图床和博客示例,这个被封禁,所有资料都迁移不了

缘由

网上查了一圈,发现github被封,很少能申诉成功的,所以我给官方发了一封邮件,想看看是什么原因导致的,避免后续再出现类似的问题

给官方回了一个邮件后,过了半个小时我收到了回复

分享一次我github被封的经历以及迁移指南,github,网络协议,网络,go,前端,ssl,原力计划

原来问题是这样,因为我之前找某宝开通了copilot学生认证,导致被github查到封禁了,至于之所以找某宝,是因为我没有visa卡支付起来麻烦,又想体验copilot,没办法才出此下策,所以copilot学生认证还是不要绑定自己的github账号吧

分享一次我github被封的经历以及迁移指南,github,网络协议,网络,go,前端,ssl,原力计划

迁移

封都已经封了,这时候就得统计损失了,尽量挽回

所幸我很多仓库本地都有备份,重新注册了一个github账号上传就行,为此我还专门写了些脚本

备份star

很多同学都会把star当做书签收集

这时候可以通过访问github api进行备份

https://api.github.com/users/[username]/starred

分享一次我github被封的经历以及迁移指南,github,网络协议,网络,go,前端,ssl,原力计划文章来源地址https://www.toymoban.com/news/detail-663352.html

批量备份issue到本地

const fs = require('fs');
const axios = require('axios');
const sanitize = require('sanitize-filename');
const { githubRepoOwner, githubRepoName, githubAccessToken } = require('./config');

async function getIssues() {
  let allIssues = [];
  let page = 1;
  let perPage = 300; // 每页返回100个issue,根据实际情况可以适当调整

  try {
    while (true) {
      const response = await axios.get(`https://api.github.com/repos/${githubRepoOwner}/${githubRepoName}/issues`, {
        params: {
          page,
          per_page: perPage
        },
        headers: {
          Authorization: `Bearer ${githubAccessToken}`
        }
      });

      const issues = response.data;
      if (issues.length === 0) {
        break; // 退出循环,表示已获取所有issue数据
      }

      allIssues = allIssues.concat(issues);
      page++;
    }

    return allIssues;
  } catch (error) {
    throw new Error(`Error fetching issues: ${error.message}`);
  }
}

async function saveIssueAsMarkdown(issue, directory) {
  const markdownContent = issue.body;
  const fileName = `${directory}/${sanitize(issue.title)}.md`;
  fs.writeFileSync(fileName, markdownContent);
}

async function main() {
  try {
    const issues = await getIssues();

    // Create a directory for each label
    issues.forEach(issue => {
      issue.labels.forEach(label => {
        const directory = `./docs/${sanitize(label.name)}`;
        if (!fs.existsSync(directory)) {
          fs.mkdirSync(directory, { recursive: true });
        }
        saveIssueAsMarkdown(issue, directory);
      });
    });

    console.log('Markdown files saved successfully!');
  } catch (error) {
    console.error(error.message);
  }
}

main();

批量更新issue标题

const { Octokit } = require('@octokit/rest');

// GitHub personal access token
const token = '';

// GitHub repository information
const owner = 'LQ-vic';
const repo = 'code-interview';

const labelToFilter = 'image'; // 请替换为你想筛选的标签

const octokit = new Octokit({ auth: token });

async function updateIssueTitlesByLabel() {
  try {
    // 根据标签获取仓库的所有 issues
    const issues = await octokit.issues.listForRepo({
      owner,
      repo,
      state: 'open', // 只获取打开的 issues
      labels: labelToFilter,
      per_page: 100, // 每页获取 100 个 issues,你可以根据需要调整
    });

    for (const issue of issues.data) {
      if (issue.title.startsWith('xx:xx:')) {
        const newTitle = issue.title.replace('xx:xx:', 'xx:');
        await octokit.issues.update({
          owner,
          repo,
          issue_number: issue.number,
          title: newTitle,
        });
        console.log(`Updated issue #${issue.number} title to: ${newTitle}`);
      }
    }
  } catch (error) {
    console.error('Error updating issue titles:', error.message);
  }
}

updateIssueTitlesByLabel();


批量上传issue

const fs = require('fs');
const path = require('path');
const { Octokit } = require('@octokit/rest');

// GitHub personal access token
const token = '';

// GitHub repository information
const owner = 'LQ-vic';
const repo = 'code-interview';

// Directory path of the docs folder
const docsDirectory = './docs/CSS3';

// Labels to be added to each issue
const labelColors = [
  { name: 'CSS3', color: '#FBCA033' }
];
const excludedDirectories = ['.vuepress', '.git', 'node_modules'];

// File path to store the uploaded files record
const recordFilePath = './uploaded_files.txt';

// Initialize Octokit
const octokit = new Octokit({ auth: token });

// Function to read all Markdown files in the given directory
async function readMarkdownFiles(directory) {
  const files = fs.readdirSync(directory);

  for (const file of files) {
    // console.log('file',file)
    const filePath = path.join(directory, file);
    const stat = fs.statSync(filePath);

    if (stat.isDirectory() && !excludedDirectories.includes(file)) {
      await readMarkdownFiles(filePath); // Recursively read files in non-excluded subdirectories
    } else if (stat.isFile() && path.extname(file) === '.md') {
      const content = fs.readFileSync(filePath, 'utf8');
      const title = extractTitleFromContent(content);
      if (!isFileUploaded(title)) {
        await createIssue(title, content, labelColors);
        addUploadedFile(title);
      }
    }
  }
}

// Function to create GitHub issue
async function createIssue(title, body, labels) {
  try {
    const response = await octokit.issues.create({
      owner: owner,
      repo: repo,
      title: `${title}`,
      body: body,
      labels: labels
    });

    console.log(`Successfully created issue: ${title}`);
  } catch (error) {
    console.log(`Failed to create issue: 面试官:${title}`);
    console.log(`Error: ${error.message}`);
  }
}

// Function to extract title from the content (first heading)
function extractTitleFromContent(content) {
  const match = content.match(/^#\s*(.+)/);
  if (match) {
    return match[1];
  }
  return '';
}

// Function to check if a file has been uploaded
function isFileUploaded(filename) {
  if (fs.existsSync(recordFilePath)) {
    const uploadedFiles = fs.readFileSync(recordFilePath, 'utf8').split('\n');
    return uploadedFiles.includes(filename);
  }
  return false;
}

// Function to add uploaded file to the record
function addUploadedFile(filename) {
  fs.appendFileSync(recordFilePath, filename + '\n', 'utf8');
}

// Read all Markdown files in the docs directory (excluding specified directories) and create issues
readMarkdownFiles(docsDirectory)
  .then(() => {
    console.log('All issues created.');
  })
  .catch((error) => {
    console.log('Error:', error);
  });

批量导出issue目录

const axios = require('axios');
const fs = require('fs');


async function getGitHubIssues(owner, repo, labels, token) {
  const baseUrl = `https://api.github.com/repos/${owner}/${repo}/issues`;
  const headers = token ? { Authorization: `token ${token}` } : {};
  const params = { state: 'all', per_page: 100 };
  const issuesByLabel = {};

  let nextPage = true;
  while (nextPage) {
    try {
      const response = await axios.get(baseUrl, { headers, params });
      const data = response.data;

      if (!data.length) break;

      data.forEach((issue) => {
        if (!issue.pull_request) {
          issue.labels.forEach((label) => {
            if (labels.includes(label.name)) {
              if (!issuesByLabel[label.name]) {
                issuesByLabel[label.name] = [];
              }
              issuesByLabel[label.name].push(issue);
            }
          });
        }
      });

      if (response.headers.link) {
        const links = response.headers.link.split(', ');
        nextPage = links.some((link) => link.endsWith('rel="next"'));
        if (nextPage) {
          const nextPageNum = parseInt(links[links.length - 1].match(/&page=(\d+)/)[1], 10);
          params.page = nextPageNum;
        }
      } else {
        nextPage = false;
      }
    } catch (error) {
      throw new Error(`Failed to fetch issues. Error: ${error.message}`);
    }
  }

  return issuesByLabel;
}


// Output to Markdown file
function writeIssuesToMarkdown(issues, outputPath) {
  let content = '';

  Object.entries(issues).forEach(([label, issuesList]) => {
    content += `## ${label}\n\n`;
    issuesList.forEach((issue) => {
      content += `- [${issue.title}](${issue.html_url})\n`;
    });
    content += '\n';
  });

  fs.writeFile(outputPath, content, (err) => {
    if (err) {
      console.error('Error writing the file:', err);
    } else {
      console.log('Markdown file generated successfully!');
    }
  });
}


// 使用示例
const owner = 'LQ-vic';
const repo = 'code-interview';
const labels = ['JavaScript', 'TypeScript','vue','vue3','react','HTTP','webpack','nodejs','Linux','git','CSS','CSS3','组件库','小程序'];
const token = '';
const outputPath = 'dirname.md';

(async () => {
  try {
    const issues = await getGitHubIssues(owner, repo, labels, token);
    writeIssuesToMarkdown(issues, outputPath);
  } catch (error) {
    console.error(error.message);
  }
})();

到了这里,关于分享一次我github被封的经历以及迁移指南的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 一次违法网站的渗透经历

    0x01 前言 在一次攻防演练中,我发现了一个有趣的渗透路径。在信息收集阶段,我注意到目标网站和用户资产网站共享相同的IP网段。这意味着它们可能在同一台服务器上托管,或者至少由同一家互联网服务提供商管理。这种情况为我们的渗透测试提供了一个有利的条件,因

    2024年04月26日
    浏览(27)
  • 一次有趣的Webshell分析经历

    在对某目标做敏感目录收集时发现对方网站备份源代码在根目录下的 backup.tar.gz ,遂下载,先使用D盾分析有没有之前黑客遗留的webshell后门 通过逐个webshell后门分析,最终锁定了一个伪装加密的webshell文件,文件名为: GetSMSSendStatus.php 黑客将后门文件伪装成正常的程序功能,

    2024年02月14日
    浏览(29)
  • 记一次搞崩ubuntu系统的经历

    本来想在ubuntu系统上安装一个windows系统,没想成在对磁盘进行分区的时候出错了,导致进入了grub模型,一直出不来, 过程中一些很好的链接放上来哈 市面上很少有的 基于linux系统安装另外一个系统 的(感觉是非常靠谱的,是我操作菜): B站版:环境搭建: 双系统: 基于U

    2024年02月16日
    浏览(25)
  • 记一次卡顿的性能优化经历实操

    本篇的性能优化不是八股文类的优化方案,而是针对具体场景,具体分析,从排查卡顿根因到一步步寻找解决方案,甚至是规避等方案来最终解决性能问题的经历实操 所以,解决方案可能不通用,不适用于你的场景,但这个解决过程是如何一步步去处理的,解决思路是怎么样

    2024年02月02日
    浏览(29)
  • OpenApi接口的一次调用经历(附代码)

    去弄一个api_key:https://platform.openai.com/account/api-keys   先看所有能用的模型: 返回: babbage davinci text-davinci-edit-001 babbage-code-search-code text-similarity-babbage-001 code-davinci-edit-001 text-davinci-001 ada curie-instruct-beta babbage-code-search-text babbage-similarity whisper-1 code-search-babbage-text-001 text-curie-

    2024年02月12日
    浏览(40)
  • 记一次docker-compose的坎坷安装经历

            最近公司在做一个kafka项目,所以想用docker来安装kafka集群,所以安装完docker后就准备安装docker-compose,但在安装过程中确碰到了各种问题,搞了两个半天再通过翻墙工具才终于搞定。         首先看了篇文章显示安装前要对应docker版本。 compose文件格式版本

    2024年02月11日
    浏览(30)
  • 一次某某云上的redis读超时排查经历

    性能排查,服务监控方面的知识往往涉及量广且比较零散,如何较为系统化的分析和解决问题,建立其对性能排查,性能优化的思路,我将在这个系列里给出我的答案。 最近一两天线上老是偶现的redis读超时报警,并且是 业务低峰期间 ,甚是不解,于是开始着手排查。 以下

    2024年02月14日
    浏览(35)
  • 编译时注解处理器的一次使用经历

    编译时注解处理器在《深入理解Java虚拟机》一书中有一些介绍(前端编译篇有提到),但一直没有机会使用,直到碰到这个需求,觉得再合适不过了,就简单用了一下,这里做个记录。------原文写于2021年2月8日。 我们为公司提供了一套通用的JAVA组件包,组件包内有不同的模

    2024年02月12日
    浏览(31)
  • 简单记录一次帮维修手机经历(Vivo x9)

    手边有一台朋友亲戚之前坏掉的Vivo X9手机, 一直说要我帮忙修理一下, 我一直是拒绝的, 因为搞程序的不等于维修的(会电脑不等于维修电器),不知道这种思路如何根深蒂固的,不过好吧, 今天无聊了, 拆一拆… 1. 充电 在充了差不多半个小时到一个小时的电之后开始

    2024年04月17日
    浏览(27)
  • 记一次Selenium框架的爬虫遇到下拉框页面的解决经历

    最近有一个项目需要使用爬虫从某网站抓取全国的医院名称,等级,地址等信息 爬取的url为https://some/website/that/i/can/tell/you/sorry 用浏览器打开这个url会发现,切换不同的省市需要点击左上角的下拉框进行选择 通常遇到这种下拉框页面,我们第一时间想到使用Selenium框架的Sel

    2024年01月21日
    浏览(30)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包