Skip to content
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

Feature GitHub deploy #1053

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"lint": "vue-cli-service lint"
},
"dependencies": {
"@fehey/monaco-markdown": "^0.0.3",
"@iktakahiro/markdown-it-katex": "^3.1.0",
"@octokit/rest": "^18.10.0",
"@sentry/electron": "^1.2.0",
"ant-design-vue": "^1.3.5",
"axios": "^0.18.1",
Expand All @@ -37,6 +39,7 @@
"junk": "^3.1.0",
"less": "^3.9.0",
"lowdb": "^1.0.0",
"ls-all": "^1.1.0",
"macaddress": "^0.2.9",
"markdown-it": "^8.4.2",
"markdown-it-abbr": "^1.0.4",
Expand All @@ -50,7 +53,6 @@
"markdown-it-sup": "^1.0.0",
"markdown-it-toc-and-anchor": "^4.2.0",
"moment": "^2.24.0",
"monaco-markdown": "^0.0.6",
"node-ssh": "^6.0.0",
"normalize-path": "^3.0.0",
"prismjs": "^1.16.0",
Expand Down
10 changes: 9 additions & 1 deletion src/components/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
</a-layout>

<a-modal :visible="syncErrorModalVisible" :footer="null" @cancel="syncErrorModalVisible = false" :maskClosable="false">
🙁 {{ $t('syncError1') }} <a @click="openInBrowser('https://gridea.dev/')">FAQ</a> {{ $t('or') }} <a @click="openInBrowser('https://github.com/getgridea/gridea/issues')">Issues</a> {{ $t('syncError2') }}
<div>🙁 {{ $t('syncError1') }} <a @click="openInBrowser('https://gridea.dev/')">FAQ</a> {{ $t('or') }} <a @click="openInBrowser('https://github.com/getgridea/gridea/issues')">Issues</a> {{ $t('syncError2') }}</div>
<div class="sync-error-message">{{ syncErrorMessage }}</div>
</a-modal>

<a-modal title="🔥 New Version" :visible="updateModalVisible" :footer="null" @cancel="updateModalVisible = false" :maskClosable="false">
Expand Down Expand Up @@ -124,6 +125,8 @@ export default class App extends Vue {

syncErrorModalVisible = false

syncErrorMessage = ''

updateModalVisible = false

systemModalVisible = false
Expand Down Expand Up @@ -260,6 +263,7 @@ export default class App extends Vue {
ga.event('Publish', 'Publish - success', { evLabel: this.site.setting.domain })
} else {
this.syncErrorModalVisible = true
this.syncErrorMessage = result.message

ga.event('Publish', 'Publish - failed', { evLabel: this.site.setting.domain })
}
Expand Down Expand Up @@ -532,4 +536,8 @@ export default class App extends Vue {
padding: 16px 0;
background: #fafafa;
}

.sync-error-message {
margin-top: 16px;
}
</style>
2 changes: 1 addition & 1 deletion src/components/MonacoMarkdownEditor/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Vue, Component, Prop, Watch, Model,
} from 'vue-property-decorator'
import * as monaco from 'monaco-editor'
import * as MonacoMarkdown from 'monaco-markdown'
import * as MonacoMarkdown from '@fehey/monaco-markdown'
import theme from './theme'

@Component
Expand Down
11 changes: 9 additions & 2 deletions src/server/events/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { ipcMain, IpcMainEvent } from 'electron'
import Deploy from '../deploy'
import Renderer from '../renderer'
import SftpDeploy from '../plugins/deploys/sftp'
import GitHubDeploy from '../plugins/deploys/github'

export default class DeployEvents {
constructor(appInstance: any) {
const { platform } = appInstance.db.setting

const deploy = new Deploy(appInstance)
const sftp = new SftpDeploy(appInstance)
const github = new GitHubDeploy(appInstance)
const renderer = new Renderer(appInstance)

ipcMain.removeAllListeners('site-publish')
Expand All @@ -18,23 +20,28 @@ export default class DeployEvents {

ipcMain.on('site-publish', async (event: IpcMainEvent, params: any) => {
const client = ({
'github': deploy,
'github': github,
'coding': deploy,
'sftp': sftp,
} as any)[platform]

// render
console.time('site-publish-render')

renderer.db.themeConfig.domain = renderer.db.setting.domain
await renderer.renderAll()
console.timeEnd('site-publish-render')

// publish
console.time('site-publish')
const result = await client.publish()
console.timeEnd('site-publish')
event.sender.send('site-published', result)
})

ipcMain.on('remote-detect', async (event: IpcMainEvent, params: any) => {
const client = ({
'github': deploy,
'github': github,
'coding': deploy,
'sftp': sftp,
} as any)[platform]
Expand Down
Loading