Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 49 additions & 0 deletions .github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy documentation to GitHub Pages

on:
workflow_run:
workflows: ['make-release']
types:
- completed

workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: true

jobs:
build:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Pages
uses: actions/configure-pages@v3

- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./docs
destination: ./_site

- name: Upload artifact
uses: actions/upload-pages-artifact@v1

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
86 changes: 82 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,84 @@
# example-automatic-deploy-ts-app-to-npm-with-scope
# Example: Automatic Deployment of TypeScript App to npm with Scope

Pass next secrets to github actions
## Overview
This guide outlines the steps to automatically deploy a TypeScript application to npm with a specific scope using GitHub Actions. By setting up this workflow, you can streamline the process of updating and publishing your package to npm, ensuring seamless integration with your development pipeline.

- GH_TOKEN
- NPM_TOKEN
## Prerequisites
Before proceeding, make sure you have the following:

- Access to the GitHub repository containing your TypeScript project.
- An npm account with permissions to publish packages to the desired scope.
- GitHub Personal Access Token (GH_TOKEN) with the necessary permissions to push changes and trigger GitHub Actions.
- npm token (NPM_TOKEN) with permissions to publish packages.

## Workflow Setup
To automate the deployment process, follow these steps:

1. **Create Secrets**: In your GitHub repository, navigate to "Settings" > "Secrets" and add the following secrets:
- `GH_TOKEN`: GitHub Personal Access Token.
- `NPM_TOKEN`: npm token.

2. **Configure GitHub Actions Workflow**: Create or modify your GitHub Actions workflow file (e.g., `.github/workflows/deploy.yml`) to define the deployment steps. Below is a sample workflow file:

```yaml
name: make-release

on:
push:
branches:
- master

jobs:

runner-job:
runs-on: ubuntu-latest

steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Install dependencies
run: npm ci

- name: Run Tests
run: npm test

release:
name: Release
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies and build 🔧
run: npm ci && npm run build

- name: Make Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
```

This workflow triggers on pushes to the `main` branch. It installs dependencies, builds the project, and then publishes it to npm.

3. **Commit and Push Changes**: Commit the workflow file changes to your repository and push them to GitHub. This action triggers the workflow defined in the YAML file.

4. **Monitor Deployment**: Once the workflow is triggered, monitor its progress in the "Actions" tab of your GitHub repository. You should see the workflow executing the defined steps.

5. **Verify Deployment**: After successful execution, verify that your TypeScript application has been deployed to npm with the specified scope.

## Conclusion
By implementing this GitHub Actions workflow, you've automated the process of deploying your TypeScript application to npm, saving time and ensuring consistency in your development workflow. With secrets management and continuous integration in place, you can confidently publish updates to your npm package with ease.

Happy coding!
Empty file added docs/.nojekyll
Empty file.
1 change: 1 addition & 0 deletions docs/assets/img/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/assets/img/npm.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Document</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple.css">
</head>

<body>
<div id="app"></div>
<script>
window.$docsify = {
// GENERAL
// -----------------------------------------------------------------
name: 'example-automatic-deploy-ts-app-to-npm-with-scope',
repo: 'https://github.com/JS-AK/example-automatic-deploy-ts-app-to-npm-with-scope',
homepage: 'index.md',
loadSidebar: 'sidebar.md',

// NAVIGATION
// -----------------------------------------------------------------
alias: {
'.*?/changelog': 'https://raw.githubusercontent.com/JS-AK/example-automatic-deploy-ts-app-to-npm-with-scope/master/CHANGELOG.md',
},
auto2top: true,
maxLevel: 3,
subMaxLevel: 3,


// PLUGINS
// -----------------------------------------------------------------
executeScript: true,
search: {
depth: 3,
noData: 'No results!',
placeholder: 'Search...'
},
plugins: [
// Restores initial <title>
function persistTitle(hook, vm) {
var titleElm = document.querySelector('title');
var rootTitle = titleElm && titleElm.textContent;
var pageTitlePrefix = window.$docsify.name ? window.$docsify.name + ' - ' : '';

if (rootTitle) {
hook.doneEach(function () {
var currentTitle = titleElm.textContent;
var isRoot = !/\/[a-z]/.test(location.hash);
var newTitle = isRoot ? rootTitle : pageTitlePrefix + currentTitle;

titleElm.textContent = newTitle;
});
}
}
]
}
</script>
<!-- Docsify v4 -->
<script src="https://cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify-themeable@0"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify-plugin-ethicalads@1"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify-copy-code@2"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify-pagination@2/dist/docsify-pagination.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify@4/lib/plugins/external-script.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify@4/lib/plugins/search.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1/components/prism-bash.min.js"></script>
</body>

</html>
84 changes: 84 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Example: Automatic Deployment of TypeScript App to npm with Scope

## Overview
This guide outlines the steps to automatically deploy a TypeScript application to npm with a specific scope using GitHub Actions. By setting up this workflow, you can streamline the process of updating and publishing your package to npm, ensuring seamless integration with your development pipeline.

## Prerequisites
Before proceeding, make sure you have the following:

- Access to the GitHub repository containing your TypeScript project.
- An npm account with permissions to publish packages to the desired scope.
- GitHub Personal Access Token (GH_TOKEN) with the necessary permissions to push changes and trigger GitHub Actions.
- npm token (NPM_TOKEN) with permissions to publish packages.

## Workflow Setup
To automate the deployment process, follow these steps:

1. **Create Secrets**: In your GitHub repository, navigate to "Settings" > "Secrets" and add the following secrets:
- `GH_TOKEN`: GitHub Personal Access Token.
- `NPM_TOKEN`: npm token.

2. **Configure GitHub Actions Workflow**: Create or modify your GitHub Actions workflow file (e.g., `.github/workflows/deploy.yml`) to define the deployment steps. Below is a sample workflow file:

```yaml
name: make-release

on:
push:
branches:
- master

jobs:

runner-job:
runs-on: ubuntu-latest

steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Install dependencies
run: npm ci

- name: Run Tests
run: npm test

release:
name: Release
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies and build 🔧
run: npm ci && npm run build

- name: Make Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
```

This workflow triggers on pushes to the `main` branch. It installs dependencies, builds the project, and then publishes it to npm.

3. **Commit and Push Changes**: Commit the workflow file changes to your repository and push them to GitHub. This action triggers the workflow defined in the YAML file.

4. **Monitor Deployment**: Once the workflow is triggered, monitor its progress in the "Actions" tab of your GitHub repository. You should see the workflow executing the defined steps.

5. **Verify Deployment**: After successful execution, verify that your TypeScript application has been deployed to npm with the specified scope.

## Conclusion
By implementing this GitHub Actions workflow, you've automated the process of deploying your TypeScript application to npm, saving time and ensuring consistency in your development workflow. With secrets management and continuous integration in place, you can confidently publish updates to your npm package with ease.

Happy coding!
6 changes: 6 additions & 0 deletions docs/sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- markdownlint-disable-next-line first-line-heading -->
- [Documentation](/)
- [Changelog](changelog.md)
- **Links**
- [![Github](assets/img/github.svg)Github](https://github.com/JS-AK/example-automatic-deploy-ts-app-to-npm-with-scope)
- [![NPM](assets/img/npm.svg)NPM](https://www.npmjs.com/package/@js-ak/example-automatic-deploy-ts-app-to-npm-with-scope)