Skip to content

Commit

Permalink
conf: add workflows (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush authored Jan 21, 2021
1 parent 8458837 commit 45900c0
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Docs

on:
schedule:
- cron: '0 0 * * *'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run
run: sh ./scripts/update_docs/update_docs.sh
env:
EMAIL_ADDRESS: ${{secrets.EMAIL_ADDRESS}}
GIT_NAME: ${{secrets.GIT_NAME}}
PUBLIC_REPO_TOKEN: ${{secrets.PUBLIC_REPO_TOKEN}}
24 changes: 24 additions & 0 deletions .github/workflows/unpublish_next.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Unpublish

on:
schedule:
- cron: '0 0 * * *'

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Set npmrc
run: echo //registry.npmjs.org/:_authToken=$NPM_TOKEN > ~/.npmrc
env:
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Unpublish
run: node ./scripts/unpublish/unpublish.js
49 changes: 49 additions & 0 deletions scripts/release/unpublish/unpublish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const jsnpm = require('jsnpm');

const logger = require('../../../util/logger');

const TAG_DEV = 'dev';
const TAG_NEXT = 'next';
const VERSION_REGEXP = new RegExp([TAG_NEXT, TAG_DEV].join('|'));

const unpublish = async packageName => {
const versions = await jsnpm.versions(packageName);
const taggedNext = await jsnpm.getVersion(packageName, TAG_NEXT);
const taggedDev = await jsnpm.getVersion(packageName, TAG_DEV);

const nextOnly = versions.filter(v => {
if ([taggedNext, taggedDev].includes(v)) {
return false;
}

return !!v.match(VERSION_REGEXP);
});

const one = async (i = 0) => {
const current = nextOnly[i];

if (!current) {
return;
}

logger.log(`Unpublishing: ${packageName}@${current}`);

try {
await jsnpm.unpublish(packageName, current);
} catch (e) {
logger.log(`Unable to unpublish: ${current}`, e);
}

one(++i);
};

one();
};

const runUnpublish = async () => {
await unpublish('vest');
await unpublish('eslint-plugin-vest');
await unpublish('n4s');
};

runUnpublish();
36 changes: 36 additions & 0 deletions scripts/update_docs/update_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
git config --global user.email $EMAIL_ADDRESS --replace-all
git config --global user.name $GIT_NAME

echo "Cloning Source repo"
git clone --single-branch --branch stable https://github.com/$GIT_NAME/vest.git

echo "Cloning docs branches"
git clone --single-branch --branch gh-pages https://github.com/$GIT_NAME/vest.git vest_docs
git clone --single-branch --branch gh-pages https://github.com/$GIT_NAME/n4s.git n4s_docs

echo "Retrieving Versions"
cd ./vest/packages/vest
export VEST_VERSION=$(node -pe "require('./package.json').version")
echo "VEST: $VEST_VERSION"

cd ../n4s
export N4S_VERSION=$(node -pe "require('./package.json').version")
echo "N4S: $N4S_VERSION"

cd $GITHUB_WORKSPACE

echo "Copying docs over"
cp -a ./vest/packages/vest/docs/. vest_docs/
cp -a ./vest/packages/n4s/docs/. n4s_docs/

cd vest_docs
git add .
git commit -m "$VEST_VERSION"
git push https://$PUBLIC_REPO_TOKEN@github.com/$GIT_NAME/vest.git gh-pages

cd $GITHUB_WORKSPACE

cd n4s_docs
git add .
git commit -m "$N4S_VERSION"
git push https://$PUBLIC_REPO_TOKEN@github.com/$GIT_NAME/n4s.git gh-pages

0 comments on commit 45900c0

Please sign in to comment.