Skip to content

Commit

Permalink
chore(structure)!: change paths (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
FabrizioCafolla authored Oct 2, 2023
1 parent c15b165 commit cb755af
Show file tree
Hide file tree
Showing 32 changed files with 8,922 additions and 191 deletions.
1 change: 0 additions & 1 deletion .gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 30 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
Fixes #
## Description of your changes

<!---
Include here a summary of the change.
Please include also relevant motivation and context.
Add any applicable code snippets, links, screenshots, or other resources
that can help us verify your changes.
-->

### Related issues, RFCs

<!---
Add here the number (i.e. #42) to the Github Issue or RFC that is related to this PR.
Don't include any other text, otherwise the Github Issue will not be detected.
Note: If no issue is present the PR might get blocked and not be reviewed.
-->
**Issue number:**

## Checklist

- [ ] I have performed a *self-review* of my own code
- [ ] I have *commented* my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
- [ ] I have made corresponding changes to the *documentation*
- [ ] My changes generate *no new warnings*
- [ ] I have *added tests* that prove my change is effective and works
- [ ] The PR title follows the [conventional commit semantics](https://github.com/neulabscom/neulabs-cdk-constructs/blob/main/.github/semantic.yml#L2)
58 changes: 58 additions & 0 deletions .github/scripts/upload_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/python3
import argparse
import os
import shlex
import subprocess
import sys

DEFAULT_BUCKET = 'neulabs-docs-swamp'


def main():
parser = argparse.ArgumentParser()
parser.add_argument('--base-path', type=str, default='docs/')
parser.add_argument(
'--docs-name', type=str, default='docs', help='Docs folder name'
)
parser.add_argument('--project-name', type=str, required=True)
parser.add_argument('--paths', type=str, nargs='+', default=[])

args = parser.parse_args()

if not os.path.isdir(args.base_path):
sys.tracebacklimit = 0
raise NotADirectoryError(f'"{args.base_path}" is not a directory')

folders_to_upload = [
(os.path.join(args.base_path, 'static', 'img'), ['neulabs/*']),
(os.path.join(args.base_path, 'src', 'components'), []),
(os.path.join(args.base_path, 'src', 'css'), []),
(os.path.join(args.base_path, args.docs_name), []),
(os.path.join(args.base_path, 'sidebars.js'), []),
]
for path in args.paths:
if os.path.isdir(path):
folders_to_upload.append((path, []))
continue
else:
sys.tracebacklimit = 0
raise NotADirectoryError(f'"{path}" is not a directory')

s3_base_path = f's3://{DEFAULT_BUCKET}/{args.project_name}/'

for folder, exclude in folders_to_upload:
s3_path = os.path.join(s3_base_path, folder.replace(args.base_path, ''))
exclude_path = ' '.join([f'--exclude="{e}"' for e in exclude])
if os.path.isdir(folder):
cmd = f'aws s3 sync {folder} {s3_path} --delete {exclude_path}'
else:
cmd = f'aws s3 cp {folder} {s3_path}'

print(f'Upload {folder} to {s3_path}')
print(subprocess.check_output(shlex.split(cmd)).decode('utf-8'))

return 0


if __name__ == '__main__':
sys.exit(main())
56 changes: 56 additions & 0 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Deploy Docs

on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'docs/**'

env:
PROJECT_NAME: "neulabs-cdk-constructs"
AWS_REGION: "eu-west-1"
AWS_ROLE_NAME: 'github-oidc-workflow-role'

permissions:
id-token: write
contents: read # This is required for actions/checkout

jobs:
trigger-workflow:
runs-on: ubuntu-latest
steps:
- name: Git clone the repository
uses: actions/checkout@v3

- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ env.AWS_ROLE_NAME }}
aws-region: ${{ env.AWS_REGION }}
mask-aws-account-id: no

- name: Upload docs to S3 bucket
run: |
python3 .github/scripts/upload_docs.py --project-name ${{ env.PROJECT_NAME }}
- name: Trigger deploy workflow in neulbas-docs Repository
uses: actions/github-script@v6
with:
github-token: ${{ secrets.NEULABS_MANAGE_ACTION_WORKFLOWS }}
retries: 3
script: |
const owner = 'neulabscom';
const repo = 'neulabs-docs';
const event_type = 'deploy';
const ref = 'main';
github.rest.repos.createDispatchEvent({
owner,
repo,
event_type,
client_payload: {
"project_name": process.env.PROJECT_NAME
}
});
1 change: 0 additions & 1 deletion .gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .projen/files.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions .projenrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { cdk, javascript } = require('projen');
const { cdk, javascript, typescript } = require('projen');

const cdkVersion = '2.99.0';

Expand Down Expand Up @@ -28,7 +28,8 @@ const project = new cdk.JsiiProject({
scripts: {
prepare: 'husky install',
},
jsiiVersion: '~5.0.7',
jsiiVersion: '5.0.x',
pullRequestTemplate: false,
});

project.synth();
98 changes: 76 additions & 22 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ Setup env:

## Pull Requests

...in progress
1. This project uses >= [email protected] and [email protected] for development
2. Before opening a Pull Request, please find the existing related issue or open a new one to discuss the proposed changes. A PR without a related issue or discussion has a high risk of being rejected. We are very appreciative and thankful for your time and efforts, and we want to make sure they are not wasted.
3. After your proposal has been reviewed and accepted by at least one of the project's maintainers, you can submit a pull request.
4. When opening a PR, make sure to follow the checklist inside the pull request template.

Loading

0 comments on commit cb755af

Please sign in to comment.