将忽略的dist文件夹部署到GitHub Pages

时间:2018-02-02 18:35:11

标签: git github github-pages

我为JavaScript库创建了一个Git repo。 repo还包含一个演示网站,该网站使用捆绑的库,该库在uses nduWlanTypes, nduWlanAPI; Function GetWifiChannelTest: String; var hClient: THandle; dwVersion: DWORD; ResultInt: DWORD; pIntfList: PWLAN_INTERFACE_INFO_LIST; i: DWORD; IntfGuid: TGUID; dwDataSize: DWORD; pChannelNumber: PULONG; // <-- begin Result := ''; ResultInt := WlanOpenHandle(1, nil, @dwVersion, @hClient); if ResultInt <> ERROR_SUCCESS then begin ShowMessage('Error Open Client: ' + IntToStr(ResultInt)); Exit; end; try ResultInt := WlanEnumInterfaces(hClient, nil, @pIntfList); if ResultInt <> ERROR_SUCCESS then begin ShowMessage('Error Enumerating Interfaces: ' + IntToStr(ResultInt)); Exit; end; try for i := 0 to pIntfList^.dwNumberOfItems - 1 do begin IntfGuid := pIntfList^.InterfaceInfo[i].InterfaceGuid; ResultInt := WlanQueryInterface(hClient, @IntfGuid, wlan_intf_opcode_channel_number, nil, @dwDataSize, @pChannelNumber, nil); if ResultInt = ERROR_SUCCESS then begin Result := IntToStr(pChannelNumber^); // <-- Exit; end; end; finally WlanFreeMemory(pIntfList); end; finally WlanCloseHandle(hClient, nil); end; end; 文件夹中生成。我现在想将该网站部署到GitHub Pages。

但是,我的setTimeout(function(){ return confirm('question?'); }, <duration>);中有dist/个文件夹,并希望它仍然被忽略。

有没有办法自动生成dist/分支,其中应包含.gitignore,但要将其保留在gh-pages分支之外?

4 个答案:

答案 0 :(得分:3)

提交此脚本并在构建processPayload后调用它:

dist

我用它; - )

答案 1 :(得分:1)

总结您的背景:

  • 您当前的分支是master
  • 您有一个被忽略且未跟踪的dist/文件夹
  • 它包含可以静态提供的网站的来源
  • 您希望使用dist/分支在GitHub页面上发布此gh-pages文件夹。

执行此操作的最简单方法似乎是遵循此gist中建议的工作流程 以及documentation of Yeoman

但请注意,这取决于高级命令git subtree,并且要求dist/文件夹不会被忽略并在master上进行跟踪。

然后,您可以按照有关configuration of GH Pages' publishing source的文档进行操作。

这是否解决了您的问题,或者您是否真的希望将{2}分支中的两个分支分开并且没有dist/*文件?

在后一种情况下,问题更复杂(因为工作树中未跟踪或忽略的文件可能会阻碍进程......)但您可能需要查看this project,是基于master的解决方案的替代方案,它基于Bash脚本。

(注意:我没有测试过这个“git-directory-deploy”解决方案;我在上面提到的gist中提出了建议。)

答案 2 :(得分:0)

或者,可以使用Travis CI或其他持续集成工具自动创建构建并在gh-pages分支上部署生成的文件:GitHub Pages Deployment

答案 3 :(得分:0)

感谢this blog post,我终于找到了一种方便的方法,可以从另一个分支顶部的gitignored子文件夹伪造一个提交。我个人使用它在发布专用分支中发布内置的npm软件包。

使用这种解决方案非常灵活,可以保留历史记录(无需强制推送),但是涉及更多的git内部:

#!/usr/bin/env bash

# Environment
BUILD_DIR="dist"
RELEASE_BRANCH="gh-pages"
VERSION="$(jq -r ".version" package.json)"

# Script
git fetch origin $RELEASE_BRANCH
git add -f $BUILD_DIR
tree=$(git write-tree --prefix=$BUILD_DIR)
git reset -- $BUILD_DIR
identifier=$(git describe --dirty --always)
commit=$(git commit-tree -p refs/remotes/origin/$RELEASE_BRANCH -m "Deploy $identifier as v$VERSION" $tree)
git update-ref refs/heads/$RELEASE_BRANCH $commit
git tag -a "v$VERSION" -m "Release tag for $VERSION" $commit
git push --follow-tags origin refs/heads/$RELEASE_BRANCH
相关问题