Skip to content

Commit

Permalink
new .action repository - shared deploy files
Browse files Browse the repository at this point in the history
  • Loading branch information
klh committed Aug 27, 2021
1 parent d4af3ff commit e576130
Show file tree
Hide file tree
Showing 4 changed files with 244 additions and 8 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/deploy.yml
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
60 changes: 60 additions & 0 deletions .github/workflows/encrypt.js
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);
}
150 changes: 150 additions & 0 deletions .github/workflows/login.template

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions package.json
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"
]
}

0 comments on commit e576130

Please sign in to comment.