UNPKG

build-a-npm

Version:

A tool to create and publish Node packages with automatic version bumping and GitHub integration.

52 lines (47 loc) 1.28 kB
function generateGitHubPagesWorkflow(answers) { const { githubUsername, githubRepoName, githubPagesToken } = answers; const hasToken = githubPagesToken && githubPagesToken.toLowerCase() !== 'na'; return `name: Deploy to GitHub Pages on: push: branches: - main permissions: contents: read pages: write id-token: write jobs: deploy: environment: name: github-pages url: \${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' - name: Install Dependencies run: npm install - name: Generate index.html run: npm run index - name: Setup Pages uses: actions/configure-pages@v5 - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: path: '.' - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 ${ hasToken ? `with: token: \${{ secrets.PAGES_TOKEN }}` : '' } `; } module.exports = { generateGitHubPagesWorkflow };