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

Feat/GitHub actions #2

Open
wants to merge 94 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
34fdb5c
remove duplicate routes (#2303)
redallen Dec 3, 2020
47898e7
chore(release): releasing packages [ci skip]
patternfly-build Dec 3, 2020
98bfce5
remove sleep (#2305)
redallen Dec 3, 2020
8113fa7
Fix GitHub capitalization (#2308)
andybraren Dec 8, 2020
5986546
chore(release): releasing packages [ci skip]
patternfly-build Dec 8, 2020
8cef23b
update sitemap to reflect new urls (#2311)
redallen Dec 8, 2020
b1266b6
chore(release): releasing packages [ci skip]
patternfly-build Dec 8, 2020
b930f8d
Page guidelines (#2297)
mcarrano Dec 8, 2020
0448f21
chore(release): releasing packages [ci skip]
patternfly-build Dec 8, 2020
f9838d0
Adding design guidelines for clipboard copy (#2314)
bmignano Dec 9, 2020
8007657
chore(release): releasing packages [ci skip]
patternfly-build Dec 9, 2020
5d6c564
Toggle group guidelines (#2318)
gdoyle1 Dec 14, 2020
306534b
chore(release): releasing packages [ci skip]
patternfly-build Dec 14, 2020
699dd05
removed react-datetime from source (#2321)
evwilkin Dec 14, 2020
9c124c1
chore(release): releasing packages [ci skip]
patternfly-build Dec 14, 2020
0846771
chore/release-2020.16 (#2323)
evwilkin Dec 14, 2020
a244843
chore(release): releasing packages [ci skip]
patternfly-build Dec 14, 2020
9bc7093
Fixing typos/formatting in design guidelines contribution page (#2315)
abigaeljamie Dec 15, 2020
ccb2372
chore(release): releasing packages [ci skip]
patternfly-build Dec 15, 2020
b4c4db8
chore/2020.16-release-fixes (#2325)
evwilkin Dec 15, 2020
03d8572
chore(release): releasing packages [ci skip]
patternfly-build Dec 15, 2020
c866c12
2020.16 release-highlights (#2324)
mcarrano Dec 16, 2020
c05d204
Splitter guidelines in drawer and primary-detail (#2313)
doruskova Dec 16, 2020
78c9ffd
chore(release): releasing packages [ci skip]
patternfly-build Dec 16, 2020
8c82696
Adding switch vs. checkmark guidance (#2287)
afialkoff Dec 16, 2020
69d2cc8
added UploadIcon to icons table (#2327)
evwilkin Dec 16, 2020
c427e42
chore(release): releasing packages [ci skip]
patternfly-build Dec 16, 2020
3a44241
Applying feedback to Numerics page (#2316)
afialkoff Dec 16, 2020
f5403b5
chore(release): releasing packages [ci skip]
patternfly-build Dec 16, 2020
c1c3a31
Update Contribute section on website (#2292)
mcarrano Dec 18, 2020
2fd71c4
chore(release): releasing packages [ci skip]
patternfly-build Dec 18, 2020
16a6054
Content guidance for hints, tooltips, and popovers (#2278)
abigaeljamie Dec 21, 2020
6e0fff4
chore(release): releasing packages [ci skip]
patternfly-build Dec 21, 2020
71413c9
chore(deps): bump ini from 1.3.5 to 1.3.8 (#2326)
dependabot[bot] Jan 4, 2021
a778556
chore(deps): bump json from 2.0.2 to 2.3.0 in /packages/v3 (#1992)
dependabot[bot] Jan 4, 2021
e418ac6
feat(docgen): add @propType and fix @hide (#2334)
redallen Jan 4, 2021
316035e
chore(release): releasing packages [ci skip]
patternfly-build Jan 4, 2021
6c1544a
add action
redallen Dec 2, 2020
7043ff9
remove circleci
redallen Dec 2, 2020
8395775
add on PR
redallen Dec 2, 2020
65a05a8
syntax
redallen Dec 2, 2020
cf9d814
tweak
redallen Dec 2, 2020
fd6a3e4
tweak
redallen Dec 2, 2020
2118631
tweak
redallen Dec 2, 2020
1a9a5b3
tweak
redallen Dec 2, 2020
be0a904
tweak
redallen Dec 2, 2020
704f342
tweak
redallen Dec 2, 2020
98aefe5
tweak
redallen Dec 2, 2020
097d15e
tweak
redallen Dec 2, 2020
6c65e2a
tweak
redallen Dec 2, 2020
23cc017
tweak
redallen Dec 2, 2020
7778884
tweak
redallen Dec 2, 2020
7ab3d8b
tweak
redallen Dec 2, 2020
aa8641b
add @octokit/rest
redallen Dec 3, 2020
1844129
tweak
redallen Dec 3, 2020
ce2d646
tweak
redallen Dec 3, 2020
a68aa91
tweak
redallen Dec 3, 2020
01e690e
tweak
redallen Dec 3, 2020
5c8bf36
tweak
redallen Dec 3, 2020
0955b03
tweak
redallen Dec 3, 2020
abbcc0a
tweak
redallen Dec 3, 2020
ad6ab64
tweak
redallen Dec 3, 2020
fc781d0
tweak
redallen Dec 3, 2020
595bb89
tweak
redallen Dec 3, 2020
e86451c
add deps
redallen Dec 3, 2020
0cdbf81
tweak
redallen Dec 3, 2020
c9f435c
tweak
redallen Dec 3, 2020
64952b4
tweak
redallen Jan 4, 2021
94e7c76
tweak
redallen Jan 4, 2021
f099525
yarn install
redallen Jan 4, 2021
ba82a3f
add back workspace
redallen Jan 4, 2021
b35dc02
use /github/workspace
redallen Jan 4, 2021
da2ec14
revert
redallen Jan 4, 2021
d8e38ef
try $HOME
redallen Jan 4, 2021
b136ff7
try $HOME
redallen Jan 4, 2021
c66a345
try deployment_basepath
redallen Jan 4, 2021
39b73ae
single job
redallen Jan 5, 2021
0f79b05
fix v3 build
redallen Jan 5, 2021
39e9ed2
fix v3 upload
redallen Jan 5, 2021
345f671
try upload staging
redallen Jan 5, 2021
1ffc9cb
cache v3 build
redallen Jan 5, 2021
8871350
annotate
redallen Jan 5, 2021
19b5414
caching
redallen Jan 5, 2021
d74eefe
log less
redallen Jan 5, 2021
9e1cec2
detailed size report
redallen Jan 5, 2021
a078369
only deploy on master
redallen Jan 5, 2021
97167d6
Merge remote-tracking branch 'upstream/master' into feat/github-actions
redallen Jan 5, 2021
05226a3
remove unused yarn.lock
redallen Jan 5, 2021
179a5ca
cleanup
redallen Jan 5, 2021
c4775b2
bump
redallen Jan 6, 2021
2a8439c
add on pr
redallen Jan 6, 2021
4059418
tweak
redallen Jan 6, 2021
6ce9fee
add back circleci
redallen Jan 6, 2021
847fecd
don't deploy from gh actions
redallen Jan 6, 2021
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
key: *js_deps_cache_key
build_v3:
docker:
- image: circleci/ruby:latest-node
- image: circleci/ruby:2-node
steps:
- checkout
- restore_cache:
Expand Down
42 changes: 42 additions & 0 deletions .github/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
GIT_USERNAME="patternfly-build"
GH_REPO=${GITHUB_REPOSITORY}
REPO="github.com:${GH_REPO}.git"
echo "Preparing release environment..."
git config user.email "[email protected]"
git config user.name ${GIT_USERNAME}
git config credential.helper store
echo "https://${GIT_USERNAME}:${GH_TOKEN}@${REPO}" > ~/.git-credentials
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc

echo "Doing a release..."
# Lerna is complicated. Commands: https://github.com/lerna/lerna/tree/master/commands
# Identify packages that have been updated since the previous tagged release
# Update their versions and changelogs according to angular commit guidelines
# https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit

# Grab the log before lerna makes a commit
LOG=$(git log --format="%s" -1 | grep -Poe "#\d+")
PR_NUM=${LOG:1}

yarn run lerna publish --conventional-commits --create-release=github --yes 2>&1 | tee lerna-output.txt

if grep -i "Successfully published" lerna-output.txt; # Leave a Github comment
then
if [ -n "${PR_NUM}" ]
then
# Use Issues api instead of PR api because
# PR api requires comments be made on specific files of specific commits
GH_PR_COMMENTS="https://api.github.com/repos/${GH_REPO}/issues/${PR_NUM}/comments"
COMMENT=$(git log --author="patternfly-build" -1 --pretty=%B | tail -n +2 | python -c 'import json,sys; print(json.dumps(sys.stdin.read()))' | cut -d '"' -f 2)
JSON="{\"body\":\"Your changes have been released in: ${COMMENT}Thanks for your contribution! :tada:\"}"
echo "Adding github PR comment ${GH_PR_COMMENTS} ${JSON}"
curl -H "Authorization: token ${GH_PR_TOKEN}" --request POST "${GITHUB_PR_COMMENTS}" --data "${JSON}"
fi
elif grep -i "No changed packages to publish" lerna-output.txt;
then
echo "No changed packages to publish"
else
echo "Failed lerna publish"
exit 1
fi
88 changes: 88 additions & 0 deletions .github/upload-preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
const path = require('path');
const { Octokit } = require('@octokit/rest')
const octokit = new Octokit({ auth: process.env.GH_PR_TOKEN });
const surge = require('surge');
const publishFn = surge().publish();

// From github actions
const ghrepo = process.env.GITHUB_REPOSITORY || '';
const ghref = process.env.GITHUB_REF || '';

// From CircleCI
const owner = process.env.CIRCLE_PROJECT_USERNAME || ghrepo.split('/')[0]; // patternfly
const repo = process.env.CIRCLE_PROJECT_REPONAME || ghrepo.split('/')[1];
const prnum = process.env.CIRCLE_PR_NUMBER || (ghref.match(/pull\/(\d+)/) || [])[1];
// Can contain special characters but surge replaces them
const branch = process.env.CIRCLE_BRANCH || ghref.replace('refs/heads/', '');

const uploadFolder = process.argv[2];
const uploadName = process.argv[3] || uploadFolder;
if (!uploadFolder) {
console.log('Usage: upload-preview uploadFolder');
process.exit(1);
}

const uploadFolderName = path.basename(uploadFolder);
let uploadURL = `${repo}-${prnum ? `pr-${prnum}` : branch}`.replace(/[\/|\.]/g, '-');

uploadURL += `-${uploadName}`;
uploadURL += '.surge.sh';

publishFn({
project: uploadFolder,
p: uploadFolder,
domain: uploadURL,
d: uploadURL,
e: 'https://surge.surge.sh',
endpoint: 'https://surge.surge.sh'
});

function tryAddComment(comment, commentBody) {
if (!commentBody.includes(comment)) {
return comment;
}
return '';
}

if (prnum) {
octokit.issues.listComments({
owner,
repo,
issue_number: prnum
})
.then(res => res.data)
.then(comments => {
let commentBody = '';
const existingComment = comments.find(comment => comment.user.login === 'patternfly-build');
if (existingComment) {
commentBody += existingComment.body.trim();
commentBody += '\n';
}

if (uploadName === 'v3') {
commentBody += tryAddComment(`PF3 preview: https://${uploadURL}/v3`, commentBody);
}
else if (uploadName === 'v4') {
commentBody += tryAddComment(`PF4 preview: https://${uploadURL}/v4`, commentBody);
}
else if (uploadFolderName === 'coverage') {
commentBody += tryAddComment(`A11y report: https://${uploadURL}`, commentBody);
}

if (existingComment) {
octokit.issues.updateComment({
owner,
repo,
comment_id: existingComment.id,
body: commentBody
}).then(() => console.log('Updated comment!'));
} else {
octokit.issues.createComment({
owner,
repo,
issue_number: prnum,
body: commentBody
}).then(() => console.log('Created comment!'));
}
});
}
17 changes: 17 additions & 0 deletions .github/upload-staging.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
aws s3 rm --recursive s3://patternfly-org-staging
# TODO: Proper S3 meta tags for redirects
aws s3 sync build/patternfly-org s3://patternfly-org-staging --exclude "*" \
--include "*.html" \
--include "*.json" \
--exclude "static/**/*.json" \
--include "sw.js" \
--cache-control "public, max-age=0, must-revalidate"

aws s3 sync build/patternfly-org s3://patternfly-org-staging --include "*" \
--exclude "*.html" \
--exclude "*.json" \
--include "static/**/*.json" \
--exclude "sw.js" \
--cache-control "public, max-age=31536000, immutable"

aws cloudfront create-invalidation --distribution-id EQE4NPRH0CQXJ --paths "/*"
88 changes: 88 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: build-deploy
on:
push:
pull_request:
branches:
# Branches from forks have the form 'user:branch-name' so we only run
# this job on pull_request events for branches that look like fork
# branches. Without this we would end up running this job twice for non
# forked PRs, once for the push and then once for opening the PR.
- '**:**'jobs:
build-deploy:
runs-on: ubuntu-latest
env:
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
GH_PR_TOKEN: ${{ secrets.GH_PR_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'
- uses: actions/cache@v2
id: yarn-cache
name: Load v3 and v4 npm deps from cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
- run: yarn install --frozen-lockfile
if: steps.yarn-cache.outputs.cache-hit != 'true'
# v4 build
- uses: actions/cache@v2
id: v4-cache
name: Load webpack cache
with:
path: 'packages/v4/.cache'
key: ${{ runner.os }}-v4-${{ hashFiles('yarn.lock') }}
- run: yarn build:v4
name: Build docs
- run: node .github/upload-preview.js build/patternfly-org v4
name: Upload docs
# v3 build
- uses: actions/cache@v2
id: v3-artifact-cache
name: Load v3 artifact from cache
with:
path: 'build/patternfly-org/v3'
key: ${{ runner.os }}-build-${{ hashFiles('packages/v3/*', 'packages/v3/**') }}
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
if: steps.v3-artifact-cache.outputs.cache-hit != 'true'
- run: cd packages/v3 && bundle install --jobs 4 --retry 3
name: Install v3 ruby deps
if: steps.v3-artifact-cache.outputs.cache-hit != 'true'
- run: yarn build:v3
name: Build v3 docs
if: steps.v3-artifact-cache.outputs.cache-hit != 'true'
# temporarily move v4 out of the way
- run: mv build/patternfly-org/v4 build
name: Prep upload v3 docs
- run: node .github/upload-preview.js build/patternfly-org v3
name: Upload v3 docs
# only take the time to upload v3 if there's a change
if: steps.v3-artifact-cache.outputs.cache-hit != 'true'
# deploy
#- run: mv build/v4 build/patternfly-org
# name: Undo prep upload v3 docs
#- run: .github/release.sh
# env:
# GH_TOKEN: ${{ secrets.GH_TOKEN }}
# if: github.ref == 'refs/heads/master'
#- name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY}}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
# aws-region: ${{ secrets.AWS_REGION }}
# if: github.ref == 'refs/heads/master'
#- run: node scripts/writeV3Redirects.js
# if: github.ref == 'refs/heads/master'
#- run: node scripts/writeVersionPrefix.js
# if: github.ref == 'refs/heads/master'
#- run: du -sh build/patternfly-org/*
# name: Check size of docs
# if: github.ref == 'refs/heads/master'
#- run: .github/upload-staging.sh
# name: Upload docs to staging

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"develop:v4": "yarn workspace patternfly-org-4 develop",
"build": "yarn build:v4",
"build:analyze": "yarn workspace patternfly-org-4 build:analyze && yarn copy:v4",
"build:v4": "yarn workspace patternfly-org-4 build && yarn copy:v4",
"build:v3": "yarn workspace patternfly-org-3 build && yarn copy:v3",
"build:v4": "yarn workspace patternfly-org-4 build && sleep 1 && yarn copy:v4",
"copy:v3": "rm -rf build/patternfly-org/v3 && mkdir -p build/patternfly-org && cp -r packages/v3/_site build/patternfly-org/v3",
"copy:v4": "rm -rf build/patternfly-org/v4 && mkdir -p build/patternfly-org && cp -r packages/v4/public/ build/patternfly-org/v4 && cp -r build/patternfly-org/v4/assets build/patternfly-org/assets",
"copy:v4": "rm -rf build/patternfly-org/v4 && mkdir -p build/patternfly-org && cp -r packages/v4/public build/patternfly-org/v4 && cp -r build/patternfly-org/v4/assets build/patternfly-org/assets",
"clean": "lerna run clean && rm -rf build",
"serve": "serve build/patternfly-org",
"test:v4": "yarn workspace patternfly-org-4 test:a11y:ci",
Expand All @@ -31,6 +31,7 @@
]
},
"devDependencies": {
"@octokit/rest": "^16.43.2",
"glob": "^7.1.6",
"lerna": "^3.19.0",
"surge": "^0.21.3"
Expand Down
43 changes: 43 additions & 0 deletions packages/theme-patternfly-org/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,49 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.3.0](https://github.com/patternfly/patternfly-org/compare/[email protected]@0.3.0) (2021-01-04)


### Features

* **docgen:** add [@prop](https://github.com/prop)Type and fix [@hide](https://github.com/hide) ([#2334](https://github.com/patternfly/patternfly-org/issues/2334)) ([e418ac6](https://github.com/patternfly/patternfly-org/commit/e418ac67f31017a6489dbeea5e964a42e6c97cbc))





## [0.2.15](https://github.com/patternfly/patternfly-org/compare/[email protected]@0.2.15) (2020-12-15)

**Note:** Version bump only for package theme-patternfly-org





## [0.2.14](https://github.com/patternfly/patternfly-org/compare/[email protected]@0.2.14) (2020-12-14)

**Note:** Version bump only for package theme-patternfly-org





## [0.2.13](https://github.com/patternfly/patternfly-org/compare/[email protected]@0.2.13) (2020-12-08)

**Note:** Version bump only for package theme-patternfly-org





## [0.2.12](https://github.com/patternfly/patternfly-org/compare/[email protected]@0.2.12) (2020-12-03)

**Note:** Version bump only for package theme-patternfly-org





## [0.2.11](https://github.com/patternfly/patternfly-org/compare/[email protected]@0.2.11) (2020-11-30)

**Note:** Version bump only for package theme-patternfly-org
Expand Down
27 changes: 19 additions & 8 deletions packages/theme-patternfly-org/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,25 @@ const SideNavRouter = () => {
<Router id="ws-page-content-router">
{Object.entries(routes)
.map(([path, { Component, title, sources, katacodaLayout }]) => Component
? <AppRoute key={path} path={path} default={path === '/404'} child={<Component />} katacodaLayout={katacodaLayout} />
: <AppRoute key={path} path={path + '/*'} child={
<MDXTemplate
path={path}
title={title}
sources={sources}
/>
} katacodaLayout={katacodaLayout} />
? <AppRoute
key={path}
path={path}
default={path === '/404'}
child={<Component />}
katacodaLayout={katacodaLayout}
/>
: <AppRoute
key={path}
path={path + '/*'}
child={
<MDXTemplate
path={path}
title={title}
sources={sources}
/>
}
katacodaLayout={katacodaLayout}
/>
)
}
</Router>
Expand Down
2 changes: 1 addition & 1 deletion packages/theme-patternfly-org/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "theme-patternfly-org",
"description": "A unified PatternFly and PatternFly-React theme.",
"version": "0.2.11",
"version": "0.3.0",
"author": "Red Hat",
"license": "MIT",
"bin": {
Expand Down
11 changes: 10 additions & 1 deletion packages/theme-patternfly-org/scripts/tsDocgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const annotations = [
regex: /@beta/,
name: 'beta',
type: 'Boolean'
},
{
regex: /@propType\s+(.*)/,
name: 'type',
type: 'String'
}
];

Expand All @@ -26,7 +31,9 @@ function addAnnotations(prop) {
const match = prop.description.match(regex);
if (match) {
prop.description = prop.description.replace(regex, '').trim();
prop[name] = match[2] || match[1] || true;
if (name) {
prop[name] = match[2] || match[1] || true;
}
}
})
}
Expand Down Expand Up @@ -136,10 +143,12 @@ function tsDocgen(file) {
props: Object.entries(parsed.props || {})
.map(normalizeProp)
.map(addAnnotations)
.filter(prop => !prop.hide)
.sort((p1, p2) => p1.name.localeCompare(p2.name))
}));
}

module.exports = {
tsDocgen
};

Loading