forked from jeoy/github-deploy-actions
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new .action repository - shared deploy files
- Loading branch information
Showing
4 changed files
with
244 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: deploy | ||
on: | ||
push: | ||
branches: | ||
- main | ||
repository_dispatch: | ||
types: [content-change] | ||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@master | ||
- name: Build and Deploy | ||
uses: duetds/[email protected] | ||
env: | ||
COMMIT_EMAIL: [email protected] | ||
COMMIT_NAME: duetbot | ||
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
BASE_BRANCH: main | ||
DEPLOY_BRANCH: gh-pages | ||
BUILD_SCRIPT: npm install && DUET_PROJECT=${{ github.repository }} DUET_PROJECT_NAME=${{ github.event.repository.name }} DUET_TOKEN=$(echo -n ${{ github.repository }} | md5sum | awk '{print $1 $1}') npm run build:prototype | ||
FOLDER: dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* DUET ENCRYPTION CONFIGURATION | ||
*/ | ||
const CryptoJS = require('crypto-js'); | ||
const Yargs = require('yargs'); | ||
const replace = require('replace-in-file'); | ||
const namedArgs = Yargs.usage( | ||
'Usage: node ./.github/workflows/encrypt.js $DUET_TOKEN <passphrase>' | ||
).argv; | ||
const contents = namedArgs._[0].toString(); | ||
const password = namedArgs._[1].toString(); | ||
|
||
/** | ||
* Salt and encrypt prototype contents with a password. | ||
* Inspired by https://github.com/adonespitogo | ||
*/ | ||
var keySize = 256; | ||
var iterations = 1000; | ||
|
||
function encrypt(msg, password) { | ||
var salt = CryptoJS.lib.WordArray.random(128 / 8); | ||
var key = CryptoJS.PBKDF2(password, salt, { | ||
keySize: keySize / 32, | ||
iterations: iterations | ||
}); | ||
|
||
var iv = CryptoJS.lib.WordArray.random(128 / 8); | ||
var encrypted = CryptoJS.AES.encrypt(msg, key, { | ||
iv: iv, | ||
padding: CryptoJS.pad.Pkcs7, | ||
mode: CryptoJS.mode.CBC | ||
}); | ||
|
||
// Salt, iv will be hex 32 in length. | ||
// Append them to the ciphertext for use in decryption. | ||
var encryptedMsg = salt.toString() + iv.toString() + encrypted.toString(); | ||
return encryptedMsg; | ||
} | ||
|
||
// Encrypt input. | ||
var encrypted = encrypt(contents, password); | ||
var hmac = CryptoJS.HmacSHA256( | ||
encrypted, | ||
CryptoJS.SHA256(password).toString() | ||
).toString(); | ||
var encryptedMessage = hmac + encrypted; | ||
|
||
// Set options for search and replace. | ||
const options = { | ||
files: './dist/index.html', | ||
from: /{{DUET_TOKEN}}/g, | ||
to: encryptedMessage | ||
}; | ||
|
||
// Finally replace variables with encrypted strings. | ||
try { | ||
const results = replace.sync(options); | ||
} catch (error) { | ||
console.error('Error encrypting Duet prototype', error); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
{ | ||
"name": "github-deploy-actions", | ||
"version": "0.1.0", | ||
"name": "@duetds/github-deploy-actions", | ||
"version": "2.5.0", | ||
"private": true, | ||
"dependencies": { | ||
}, | ||
"scripts": { | ||
"start": "", | ||
"build": "", | ||
"test": "" | ||
"description": "This package contains Duet Design System github actions.", | ||
"bugs": { | ||
"email": "[email protected]" | ||
}, | ||
"license": "UNLICENSED", | ||
"author": "LocalTapiola Services Ltd <[email protected]>", | ||
"main": "entrypoint.sh", | ||
"files": [ | ||
".github" | ||
] | ||
} |