Continuous Deployment (#477)

* added key to sign deployed update package

* added passphrase access to decrypt key for signing

* [github-actions] renamed and disabled CI workflow

* [github-actions] added draft for CD workflow

* [github-actions] updated continuous deployment

* updated deployment script
This commit is contained in:
ronny1982 2019-10-03 22:48:27 +02:00 committed by GitHub
parent 91486f430c
commit 2624665a34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 80 additions and 20 deletions

View File

@ -0,0 +1,35 @@
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
# https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions
name: Continuous Deployment
on:
push:
branches:
- master
- '*.*.*'
jobs:
linux:
name: Ubuntu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Install NodeJS
uses: actions/setup-node@v1
with:
node-version: 10.x
- name: Install NPM Packages
run: npm install
- name: Lint
run: npm run lint
# Tests are currently disabled, because they do not work properly (unreliable)
#- name: Test
# run: npm run test
- name: Deploy (web)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HAKUNEKO_PASSPHRASE: ${{ secrets.HAKUNEKO_PASSPHRASE }}
run: npm run deploy:web

View File

@ -6,7 +6,7 @@ name: Continuous Integration
on:
push:
branches:
- master
- DISABLED
jobs:
linux:
@ -35,11 +35,4 @@ jobs:
- name: Build (web)
run: npm run build:web
- name: Test
run: npm run test
- name: HELLO WORLD
env:
PROJECT: HakuNeko
#working-directory: ${{ github.workspace }}
run: |
echo $PROJECT
ls -la
run: npm run test

View File

@ -1,7 +1,9 @@
module.exports = {
key: 'hakuneko.key',
key: 'key.pem',
passphrase: 'env:HAKUNEKO_PASSPHRASE',
build: './build/web',
// The deployment directory must match the `applicationStartupURL` configuration in the desktop
// e.g. 'https://manga-download.gihub.io/hakuneko/master/latest'
branch: 'gh-pages',
deploy: './6.0'
// The deployment directory must match the `applicationStartupURL` configuration in the desktop client
// e.g. 'https://manga-download.gihub.io/hakuneko/master/latest'
}

View File

@ -59,7 +59,7 @@ async function sslPack(archive, meta) {
process.chdir(config.build);
}
await execute(`zip -r ${archive} .`);
let signature = await execute(`openssl dgst -sha256 -hex -sign ${key} ${archive} | cut -d' ' -f2`);
let signature = await execute(`openssl dgst -sha256 -hex -sign ${key} -passin ${config.passphrase} ${archive} | cut -d' ' -f2`);
await fs.writeFile(meta, `${archive}?signature=${signature}`);
process.chdir(cwd);
}
@ -67,11 +67,12 @@ async function sslPack(archive, meta) {
/**
*
*/
async function gitCommit(glob) {
// TODO: provide user credentials to push changes
await execute(`git add ${glob}`);
async function gitCommit() {
let auth = Buffer.from(process.env.GITHUB_ACTOR + ':' + process.env.GITHUB_TOKEN).toString('base64');
await execute(`git add ${config.deploy}/*`);
await execute(`git commit -m 'deploy release: ${config.deploy}'`);
await execute(`git push`);
await execute(`git -c user.name="${user}" commit -m 'Deployed Release: ${config.deploy}'`);
await execute(`git -c http.extraheader="AUTHORIZATION: Basic ${auth}" push origin HEAD:${config.branch}`);
}
/**
@ -79,7 +80,6 @@ async function gitCommit(glob) {
*/
async function main() {
let meta = 'latest';
let glob = path.join(config.deploy, '*');
let archive = Date.now().toString(36).toUpperCase() + '.zip';
await sslPack(archive, meta);
await fs.remove(config.deploy);
@ -87,10 +87,10 @@ async function main() {
await fs.move(path.resolve(config.build, meta), path.resolve(config.deploy, meta));
await fs.move(path.resolve(config.build, archive), path.resolve(config.deploy, archive));
let stashID = await gitStashPush(glob);
await execute(`git checkout gh-pages`);
await execute(`git checkout ${config.branch} || git checkout -b ${config.branch}`);
await fs.remove(config.deploy);
await gitStashPop(stashID);
await gitCommit(glob);
await gitCommit();
}
// exit application as soon as any uncaught exception is thrown

30
key.pem Normal file
View File

@ -0,0 +1,30 @@
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,3B15F6E6C492AF7E01C6EED908FFEB27
sHGLysGfMhIqTVbxjmZ6+fRBsMXoncJyc8WVvzYmjBwO/C0lln8LxptyAG1e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