diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml new file mode 100644 index 0000000..36990c8 --- /dev/null +++ b/.github/workflows/jekyll-gh-pages.yml @@ -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 diff --git a/README.md b/README.md index 3ba7b60..2fd0aaa 100644 --- a/README.md +++ b/README.md @@ -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! diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/docs/assets/img/github.svg b/docs/assets/img/github.svg new file mode 100644 index 0000000..d2fb823 --- /dev/null +++ b/docs/assets/img/github.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/assets/img/npm.svg b/docs/assets/img/npm.svg new file mode 100644 index 0000000..37fd2c4 --- /dev/null +++ b/docs/assets/img/npm.svg @@ -0,0 +1 @@ +NPM icon \ No newline at end of file diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..d35ab69 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,73 @@ + + + + + + Document + + + + + + + +
+ + + + + + + + + + + + + diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..2fd0aaa --- /dev/null +++ b/docs/index.md @@ -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! diff --git a/docs/sidebar.md b/docs/sidebar.md new file mode 100644 index 0000000..de4ef18 --- /dev/null +++ b/docs/sidebar.md @@ -0,0 +1,6 @@ + +- [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)