Compare commits

..

No commits in common. "main" and "v3.3.0" have entirely different histories.
main ... v3.3.0

81 changed files with 33177 additions and 14497 deletions

9
.dependabot/config.yml Normal file
View File

@ -0,0 +1,9 @@
version: 1
update_configs:
- package_manager: "javascript"
directory: "/"
update_schedule: "daily"
default_labels:
- "dependencies"
commit_message:
prefix: "deps"

View File

@ -1,35 +0,0 @@
{
"name": "Node.js",
"image": "docker.pkg.github.com/peaceiris/actions-gh-pages/dev:latest",
// Use 'settings' to set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"bungcip.better-toml",
"EditorConfig.EditorConfig",
"donjayamanne.githistory",
"eamodio.gitlens",
"oderwat.indent-rainbow",
"yzhang.markdown-all-in-one",
"shd101wyy.markdown-preview-enhanced",
"christian-kohler.path-intellisense",
"lfs.vscode-emacs-friendly",
"ms-azuretools.vscode-docker",
"dbaeumer.vscode-eslint",
"firsttris.vscode-jest-runner",
"VisualStudioExptTeam.vscodeintellicode"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [3000],
// Specifies a command that should be run after the container has been created.
"postCreateCommand": "npm ci",
// Comment out the next line to run as root instead.
// "remoteUser": "runner"
}

View File

@ -6,12 +6,10 @@
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:prettier/recommended"
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended"
],
"plugins": ["@typescript-eslint"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"

View File

@ -1,52 +0,0 @@
name: User Support
description: Questions for this action
title: "support: "
labels: support
assignees: peaceiris
body:
- type: markdown
attributes:
value:
Please note we will close your issue without comment if you do not fill out the issue checklist below and provide ALL the requested information.
- type: checkboxes
attributes:
label: Checklist
description: Checklist before creating an issue.
options:
- label: "I am using the latest version of this action."
required: true
- label: "I have read the latest README and followed the instructions."
required: true
- label: "I have read the latest GitHub Actions official documentation and learned the basic spec and concepts."
required: true
- type: textarea
attributes:
label: Describe your question
description: A clear and concise description of what the question is.
validations:
required: true
- type: textarea
attributes:
label: Relevant links
description:
Links to your public repository, YAML config file, and YAML workflow file.
Please use [a permanent link](https://docs.github.com/en/github/managing-files-in-a-repository/managing-files-on-github/getting-permanent-links-to-files), not a default branch.
render: markdown
value: |
Public repository:
YAML config:
YAML workflow:
validations:
required: true
- type: textarea
attributes:
label: Relevant log output
description: Copy and paste any relevant log output here.
validations:
required: false
- type: textarea
attributes:
label: Additional context.
description: Write any other context about the question here.
validations:
required: false

View File

@ -1,52 +0,0 @@
name: Bug Report
description: Try the User Support Issue Template first.
title: 'bug: '
labels: bug
assignees: peaceiris
body:
- type: markdown
attributes:
value:
Please note we will close your issue without comment if you do not fill out the issue checklist below and provide ALL the requested information.
- type: checkboxes
attributes:
label: Checklist
description: Checklist before creating an issue.
options:
- label: "I am using the latest version of this action."
required: true
- label: "I have read the latest README and followed the instructions."
required: true
- label: "I have read the latest GitHub Actions official documentation and learned the basic spec and concepts."
required: true
- type: textarea
attributes:
label: "Describe the bug"
description: "A clear and concise description of what the bug is."
validations:
required: true
- type: textarea
attributes:
label: Relevant links
description:
Links to your public repository, YAML config file, and YAML workflow file.
Please use [a permanent link](https://docs.github.com/en/github/managing-files-in-a-repository/managing-files-on-github/getting-permanent-links-to-files), not a default branch.
render: markdown
value: |
Public repository:
YAML config:
YAML workflow:
validations:
required: true
- type: textarea
attributes:
label: Relevant log output
description: Copy and paste any relevant log output here.
validations:
required: false
- type: textarea
attributes:
label: Additional context.
description: Write any other context about the question here.
validations:
required: false

View File

@ -1,45 +0,0 @@
name: Proposal
description: Suggest an idea for this project
title: 'proposal: '
labels: proposal
assignees: peaceiris
body:
- type: markdown
attributes:
value:
Please note we will close your issue without comment if you do not fill out the issue checklist below and provide ALL the requested information.
- type: checkboxes
attributes:
label: Checklist
description: Checklist before creating an issue.
options:
- label: "I am using the latest version of this action."
required: true
- label: "I have read the latest README and followed the instructions."
required: true
- label: "I have read the latest GitHub Actions official documentation and learned the basic spec and concepts."
required: true
- type: textarea
attributes:
label: "Describe your proposal"
description: "A clear and concise description of what the proposal is."
validations:
required: true
- type: textarea
attributes:
label: "Describe the solution you'd like"
description: "A clear and concise description of what you want to happen."
validations:
required: true
- type: textarea
attributes:
label: "Describe alternatives you've considered"
description: "A clear and concise description of any alternative solutions or features you've considered."
validations:
required: false
- type: textarea
attributes:
label: "Additional context"
description: "Add any other context or screenshots about the feature request here."
validations:
required: false

31
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,31 @@
---
name: Bug report
about: Create a report to help us improve
title: 'Bug: This is a sample issue title'
labels: bug
assignees: peaceiris
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Your YAML file**
- A link to your repository
- A link to your YAML file
**Additional context**
Add any other context about the problem here.

View File

@ -1,14 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Discussions
url: https://github.com/peaceiris/actions-gh-pages/discussions
about: Ask casual questions or share your story about the GitHub Pages Action.
- name: GitHub Actions - GitHub Support Community Forum
url: https://github.community/c/code-to-cloud/github-actions/41
- name: GitHub Actions Community Forum
url: https://github.community/t5/GitHub-Actions/bd-p/actions
about: Please ask questions about GitHub Actions here.
- name: GitHub Pages Documentation
url: https://docs.github.com/en/pages
about: GitHub Pages official documentation here.
- name: GitHub Actions Documentation
url: https://docs.github.com/en/actions
about: GitHub Actions official documentation here.
- name: GitHub Pages help
url: https://help.github.com/en/github/working-with-github-pages
about: GitHub Pages documentaion here.

20
.github/ISSUE_TEMPLATE/proposal.md vendored Normal file
View File

@ -0,0 +1,20 @@
---
name: Proposal
about: Suggest an idea for this project
title: 'proposal: This is a sample title'
labels: proposal
assignees: peaceiris
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@ -1,36 +0,0 @@
labels:
- name: resolved
labeled:
issue:
body: |
This issue has been **LOCKED** because of it being resolved!
The issue has been fixed and is therefore considered resolved.
If you still encounter this or it has changed, open a new issue instead of responding to solved ones.
action: close
locking: lock
lock_reason: resolved
- name: inactive
labeled:
issue:
body: |
This issue has been marked as inactive.
If you still encounter this or it has changed, add a comment to provide further information.
- name: stale
labeled:
issue:
body: |
This issue has been **LOCKED** because of it being old.
If you still encounter this or it has changed, open a new issue.
action: close
locking: lock
lock_reason: resolved
- name: duplicate
labeled:
issue:
body: |
This issue has been closed because of duplication.
action: close
locking: lock
lock_reason: resolved

20
.github/labeler.yml vendored
View File

@ -1,20 +0,0 @@
cicd:
- .github/workflows/*
dependencies:
- .nvmrc
- package.json
- package-lock.json
documentation:
- README.md
test:
- __tests__
docker:
- .devcontainer/*
- .dockerignore
- Dockerfile
- Makefile
- docker-compose.yml

View File

@ -1,24 +0,0 @@
name: "Code Scanning"
on:
push:
branches:
- main
pull_request:
jobs:
CodeQL-Build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: javascript
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

View File

@ -1,16 +0,0 @@
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
name: 'Dependency Review'
on:
pull_request:
permissions:
contents: read
jobs:
dependency-review:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/dependency-review-action@v4

View File

@ -1,27 +0,0 @@
name: Label Commenter
on:
issues:
types:
- labeled
- unlabeled
pull_request_target:
types:
- labeled
- unlabeled
permissions:
contents: read
issues: write
pull-requests: write
jobs:
comment:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Label Commenter
uses: peaceiris/actions-label-commenter@v1
env:
RUNNER_DEBUG: 1

View File

@ -1,22 +0,0 @@
name: "Pull Request Labeler"
on:
pull_request_target:
jobs:
triage:
runs-on: ubuntu-22.04
timeout-minutes: 1
permissions: {}
steps:
# https://github.com/peaceiris/actions-github-app-token
- uses: peaceiris/actions-github-app-token@v1.1.6
id: app
with:
app_id: ${{ secrets.GH_APP_ID }}
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
# https://github.com/actions/labeler
- uses: actions/labeler@v4
with:
repo-token: "${{ steps.app.outputs.token }}"

View File

@ -1,14 +0,0 @@
name: Check Pages Status
on: page_build
jobs:
pages-status-check:
runs-on: ubuntu-22.04
steps:
- name: check status
run: |
status = '${{ github.event.build.status }}'
errormsg = '${{ github.event.build.error.message }}'
assert status == 'built', 'Status: {status}\nError: {errormsg}'.format(status, errormsg)
shell: python

View File

@ -3,11 +3,10 @@ name: Purge image cache
on:
schedule:
- cron: '54 18 * * */7'
workflow_dispatch:
jobs:
purge:
runs-on: ubuntu-22.04
runs-on: ubuntu-18.04
steps:
- run: >

View File

@ -3,14 +3,35 @@ name: Release
on:
push:
tags:
- 'v3.*.*'
- 'v3.*.*'
jobs:
release:
runs-on: ubuntu-22.04
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v4
# https://github.com/peaceiris/workflows/blob/main/create-release-npm/action.yml
- uses: peaceiris/workflows/create-release-npm@v0.20.1
- uses: actions/checkout@v2
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "${GITHUB_CONTEXT}"
- name: Install github/hub
run: |
export HUB_VERSION="2.14.1"
curl -fsSL https://github.com/github/hub/raw/40e421edd2c63d57bb8daa4bb9bbdfa21e8becf9/script/get | bash -s "${HUB_VERSION}"
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME="${GITHUB_REF##refs/tags/}"
echo "See [CHANGELOG.md](https://github.com/${GITHUB_REPOSITORY}/blob/${TAG_NAME}/CHANGELOG.md) for more details." > ./release_notes.md
RELEASE_NAME="$(jq -r '.name' ./package.json)"
sed -i "1i${RELEASE_NAME} ${TAG_NAME}\n" ./release_notes.md
./bin/hub release create \
--draft \
--prerelease \
--file ./release_notes.md \
"${TAG_NAME}"

17
.github/workflows/stale.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: "Stale"
on:
schedule:
- cron: "6 6 * * *"
jobs:
stale:
runs-on: ubuntu-18.04
steps:
- uses: actions/stale@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
stale-pr-message: 'This pull request is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
days-before-stale: 21
days-before-close: 7

105
.github/workflows/test-action.yml vendored Normal file
View File

@ -0,0 +1,105 @@
name: Test Action
on:
push:
branches:
- master
paths-ignore:
- '*.md'
pull_request:
types:
- opened
- synchronize
paths-ignore:
- '*.md'
jobs:
skipci:
runs-on: ubuntu-18.04
steps:
- run: echo "[Skip CI] ${{ contains(github.event.head_commit.message, '[skip ci]') }}"
test:
runs-on: ${{ matrix.os }}
if: contains(github.event.head_commit.message, '[skip ci]') == false
strategy:
max-parallel: 1
matrix:
os:
- 'ubuntu-18.04'
- 'macos-latest'
- 'windows-latest'
steps:
- uses: actions/checkout@v2
- name: Read .nvmrc
run: echo "::set-output name=NVMRC::$(cat .nvmrc)"
id: nvm
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'
- run: npm ci
- name: Remove lint-staged husky
run: |
npm uninstall lint-staged husky
git checkout package-lock.json package.json
- run: npm run build
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: '0.3.5'
- name: Build
working-directory: ./test_projects/mdbook
run: mdbook build
- name: Prepare tag
id: prepare_tag
if: startsWith(github.ref, 'refs/tags/')
run: |
TAG_NAME="${GITHUB_REF##refs/tags/}"
echo "::set-output name=tag_name::${TAG_NAME}"
echo "::set-output name=deploy_tag_name::deploy-${TAG_NAME}"
- name: Deploy
if: matrix.os != 'windows-latest'
uses: ./
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_branch: gh-pages
publish_dir: ./test_projects/mdbook/book
# external_repository: ''
allow_empty_commit: true
# keep_files: true
# force_orphan: true
# user_name: iris
# user_email: email@peaceiris.com
# commit_message: ${{ github.event.head_commit.message }}
# tag_name: ${{ steps.prepare_tag.outputs.deploy_tag_name }}
# tag_message: 'Deployment ${{ steps.prepare_tag.outputs.tag_name }}'
- name: Deploy
if: matrix.os == 'windows-latest'
uses: ./
with:
# deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# personal_token: ${{ secrets.PERSONAL_TOKEN }}
# publish_branch: gh-pages
publish_dir: ./test_projects/mdbook/book
# external_repository: ''
allow_empty_commit: true
# keep_files: true
# force_orphan: true
# user_name: iris
# user_email: email@peaceiris.com
# commit_message: ${{ github.event.head_commit.message }}
# tag_name: ${{ steps.prepare_tag.outputs.deploy_tag_name }}
# tag_message: 'Deployment ${{ steps.prepare_tag.outputs.tag_name }}'

View File

@ -3,180 +3,66 @@ name: 'Test'
on:
push:
branches:
- main
- master
paths-ignore:
- '*.md'
pull_request:
types:
- opened
- synchronize
paths-ignore:
- '*.md'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
skipci:
runs-on: ubuntu-18.04
steps:
- run: echo "[Skip CI] ${{ contains(github.event.head_commit.message, '[skip ci]') }}"
test:
runs-on: ${{ matrix.os }}
if: contains(github.event.head_commit.message, '[skip ci]') == false
strategy:
matrix:
os:
- 'ubuntu-22.04'
- 'ubuntu-20.04'
- 'ubuntu-latest'
- 'ubuntu-18.04'
- 'macos-latest'
- 'windows-latest'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: peaceiris/workflows/setup-node@v0.20.1
- uses: actions/checkout@v2
- name: Read .nvmrc
run: echo "::set-output name=NVMRC::$(cat .nvmrc)"
id: nvm
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version-file: ".nvmrc"
node-version: '${{ steps.nvm.outputs.NVMRC }}'
- name: Dump version
run: |
node -v
npm --version
git --version
- run: npm ci --ignore-scripts
- name: npm audit
if: startsWith(matrix.os, 'ubuntu-22.04')
run: |
npm audit > ./audit.log || true
if ! [ "$(cat ./audit.log | wc -l)" = 1 ]; then
echo "::warning::$(cat ./audit.log)"
fi
rm ./audit.log
- run: npm ci
- name: Run prettier
if: startsWith(matrix.os, 'ubuntu-22.04')
if: startsWith(matrix.os, 'ubuntu')
run: npm run format:check
- name: Run eslint
if: startsWith(matrix.os, 'ubuntu-22.04')
if: startsWith(matrix.os, 'ubuntu')
run: npm run lint
- name: Run ncc
if: startsWith(matrix.os, 'ubuntu')
run: npm run build
- run: npm test
- name: Upload test coverage as artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v1
with:
name: coverage-${{ matrix.os }}
name: coverage
path: coverage
- uses: codecov/codecov-action@v4
- name: Run ncc
run: npm run build
- name: Remove lint-staged husky
if: ${{ github.ref == 'refs/heads/main' }}
run: |
npm uninstall lint-staged husky
git checkout package-lock.json package.json
- name: Setup mdBook
if: ${{ github.ref == 'refs/heads/main' }}
uses: peaceiris/actions-mdbook@v1.2.0
- uses: codecov/codecov-action@v1
with:
mdbook-version: '0.4.5'
- name: Build site
if: ${{ github.ref == 'refs/heads/main' }}
working-directory: ./test_projects/mdbook
run: mdbook build
- name: Deploy
if: |
startsWith(matrix.os, 'ubuntu-latest') &&
github.ref == 'refs/heads/main' && github.event.repository.fork == false
uses: ./
with:
# deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_branch: gh-pages
publish_dir: ./test_projects/mdbook/book
# external_repository: ''
allow_empty_commit: true
# keep_files: true
# force_orphan: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
# commit_message: ${{ github.event.head_commit.message }}
cname: 'actions-gh-pages.peaceiris.com'
- name: Deploy
if: |
startsWith(matrix.os, 'macos') &&
github.ref == 'refs/heads/main' && github.event.repository.fork == false
uses: ./
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
# github_token: ${{ secrets.GITHUB_TOKEN }}
# personal_token: ${{ secrets.PERSONAL_TOKEN }}
publish_branch: gh-pages-macos
publish_dir: ./test_projects/mdbook/book
# external_repository: ''
allow_empty_commit: true
# keep_files: true
# force_orphan: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
# commit_message: ${{ github.event.head_commit.message }}
- name: Deploy
if: |
startsWith(matrix.os, 'windows') &&
github.ref == 'refs/heads/main' && github.event.repository.fork == false
uses: ./
with:
# deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# personal_token: ${{ secrets.PERSONAL_TOKEN }}
publish_branch: gh-pages-windows
publish_dir: ./test_projects/mdbook/book
# external_repository: ''
allow_empty_commit: true
# keep_files: true
# force_orphan: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
# commit_message: ${{ github.event.head_commit.message }}
- name: Deploy
if: |
startsWith(matrix.os, 'ubuntu-20.04') &&
github.ref == 'refs/heads/main' && github.event.repository.fork == false
uses: ./
with:
# deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages-ubuntu-20.04
publish_dir: ./test_projects/mdbook/book
# external_repository: ''
allow_empty_commit: true
# keep_files: true
# force_orphan: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
# commit_message: ${{ github.event.head_commit.message }}
- name: Deploy
if: |
startsWith(matrix.os, 'ubuntu-22.04') &&
github.ref == 'refs/heads/main' && github.event.repository.fork == false
uses: ./
with:
# deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages-ubuntu-22.04
publish_dir: ./test_projects/mdbook/book
# external_repository: ''
allow_empty_commit: true
# keep_files: true
# force_orphan: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
# commit_message: ${{ github.event.head_commit.message }}
token: ${{ secrets.CODECOV_TOKEN }}

View File

@ -2,21 +2,22 @@ name: Update major tag
on:
release:
types: [released]
types: [published]
jobs:
update:
runs-on: ubuntu-22.04
timeout-minutes: 1
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v4
- name: Update major tag
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
export TAG_NAME="${GITHUB_REF##refs/tags/}"
export TAG_MAJOR="${TAG_NAME%%.*}"
git tag --force -a "${TAG_MAJOR}" -m "Release ${TAG_NAME}"
git push --force origin "${TAG_MAJOR}"
- uses: actions/checkout@v2
- name: Update major tag
if: github.event.release.prerelease == false
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
export TAG_NAME="${GITHUB_REF##refs/tags/}"
export TAG_MAJOR="${TAG_NAME%%.*}"
git tag --force -a "${TAG_MAJOR}" -m "Release ${TAG_NAME}"
git push --force origin "${TAG_MAJOR}"

1
.husky/.gitignore vendored
View File

@ -1 +0,0 @@
_

View File

@ -1,2 +0,0 @@
npm install
git remote prune origin

View File

@ -1 +0,0 @@
npx lint-staged

2
.nvmrc
View File

@ -1 +1 @@
20.11.1
12.15.0

View File

@ -1,2 +0,0 @@
node_modules/
lib/

View File

@ -1,5 +1,5 @@
{
"printWidth": 100,
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,

1
.vscode/.gitignore vendored
View File

@ -1 +0,0 @@
*.log

View File

@ -1,4 +1,3 @@
{
"git.ignoreLimitWarning": true,
"deno.enable": false
"git.ignoreLimitWarning": true
}

File diff suppressed because it is too large Load Diff

30
Dockerfile Normal file
View File

@ -0,0 +1,30 @@
ARG NODE_VERSION
FROM node:${NODE_VERSION}-buster-slim
SHELL ["/bin/bash", "-l", "-c"]
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev autoconf \
ca-certificates \
wget \
ssh \
vim && \
rm -rf /var/lib/apt/lists/*
WORKDIR /git
ENV GIT_VERSION="2.25.0"
RUN wget -q "https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz" && \
tar -zxf "./v${GIT_VERSION}.tar.gz" && \
rm "./v${GIT_VERSION}.tar.gz" && \
cd "./git-${GIT_VERSION}" && \
make configure && \
./configure --prefix=/usr && \
make all && \
make install
WORKDIR /repo
CMD [ "bash" ]

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019 Shohei Ueda (peaceiris)
Copyright (c) 2020 Shohei Ueda (peaceiris)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

23
Makefile Normal file
View File

@ -0,0 +1,23 @@
cmd := "bash"
msg := ""
IMAGE_NAME := actions_github_pages_dev:latest
NODE_VERSION := $(shell cat ./.nvmrc)
DOCKER_BUILD := docker build . -t $(IMAGE_NAME) --build-arg NODE_VERSION=$(NODE_VERSION)
DOCKER_RUN := docker run --rm -i -t -v ${PWD}:/repo -v ~/.gitconfig:/root/.gitconfig $(IMAGE_NAME)
.PHONY: build
build:
$(DOCKER_BUILD)
.PHONY: run
run:
$(DOCKER_RUN) $(cmd)
.PHONY: test
test:
$(DOCKER_RUN) npm test
.PHONY: commit
commit:
$(DOCKER_RUN) git commit -m "$(msg)"

1332
README.md

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
/* CSS */

View File

@ -1 +0,0 @@
// JavaScript

View File

@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>

View File

@ -1 +0,0 @@
/* CSS */

View File

@ -1 +0,0 @@
// JavaScript

View File

@ -1 +0,0 @@
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners

View File

@ -1 +0,0 @@
<!-- issue template -->

View File

@ -1,7 +0,0 @@
# dependabot config
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily

View File

@ -1 +0,0 @@
name: 'Test'

View File

@ -1 +0,0 @@
/* CSS */

View File

@ -1 +0,0 @@
// JavaScript

View File

@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>

View File

@ -1 +0,0 @@
/* CSS */

View File

@ -1 +0,0 @@
// JavaScript

View File

@ -1,108 +1,37 @@
// import * as main from '../src/main';
import {Inputs} from '../src/interfaces';
import {showInputs, getInputs} from '../src/get-inputs';
import os from 'os';
import fs from 'fs';
import yaml from 'js-yaml';
import {getInputs} from '../src/get-inputs';
beforeEach(() => {
jest.resetModules();
process.stdout.write = jest.fn();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const doc: any = yaml.load(fs.readFileSync(__dirname + '/../action.yml', 'utf8'));
Object.keys(doc.inputs).forEach(name => {
const envVar = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
process.env[envVar] = doc.inputs[name]['default'];
});
});
afterEach(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const doc: any = yaml.load(fs.readFileSync(__dirname + '/../action.yml', 'utf8'));
Object.keys(doc.inputs).forEach(name => {
const envVar = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
console.debug(`delete ${envVar}\t${process.env[envVar]}`);
delete process.env[envVar];
});
});
// Assert that process.stdout.write calls called only with the given arguments.
// cf. https://github.com/actions/toolkit/blob/8b0300129f08728419263b016de8630f1d426d5f/packages/core/__tests__/core.test.ts
function assertWriteCalls(calls: string[]): void {
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
for (let i = 0; i < calls.length; i++) {
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
}
}
function getInputsLog(authMethod: string, inps: Inputs): string {
return `\
[INFO] ${authMethod}: true
[INFO] PublishBranch: ${inps.PublishBranch}
[INFO] PublishDir: ${inps.PublishDir}
[INFO] DestinationDir: ${inps.DestinationDir}
[INFO] ExternalRepository: ${inps.ExternalRepository}
[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}
[INFO] KeepFiles: ${inps.KeepFiles}
[INFO] ForceOrphan: ${inps.ForceOrphan}
[INFO] UserName: ${inps.UserName}
[INFO] UserEmail: ${inps.UserEmail}
[INFO] CommitMessage: ${inps.CommitMessage}
[INFO] FullCommitMessage: ${inps.FullCommitMessage}
[INFO] TagName: ${inps.TagName}
[INFO] TagMessage: ${inps.TagMessage}
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
[INFO] CNAME: ${inps.CNAME}
[INFO] ExcludeAssets ${inps.ExcludeAssets}
`;
}
describe('showInputs()', () => {
// eslint-disable-next-line jest/expect-expect
test('print all inputs DeployKey', () => {
process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
const inps: Inputs = getInputs();
showInputs(inps);
const authMethod = 'DeployKey';
const test = getInputsLog(authMethod, inps);
assertWriteCalls([`${test}${os.EOL}`]);
});
// eslint-disable-next-line jest/expect-expect
test('print all inputs GithubToken', () => {
delete process.env['INPUT_DEPLOY_KEY'];
process.env['INPUT_GITHUB_TOKEN'] = 'test_github_token';
const inps: Inputs = getInputs();
showInputs(inps);
const authMethod = 'GithubToken';
const test = getInputsLog(authMethod, inps);
assertWriteCalls([`${test}${os.EOL}`]);
});
// eslint-disable-next-line jest/expect-expect
test('print all inputs PersonalToken', () => {
delete process.env['INPUT_DEPLOY_KEY'];
delete process.env['INPUT_GITHUB_TOKEN'];
process.env['INPUT_PERSONAL_TOKEN'] = 'test_personal_token';
const inps: Inputs = getInputs();
showInputs(inps);
const authMethod = 'PersonalToken';
const test = getInputsLog(authMethod, inps);
assertWriteCalls([`${test}${os.EOL}`]);
});
delete process.env['INPUT_DEPLOY_KEY'];
delete process.env['INPUT_GITHUB_TOKEN'];
delete process.env['INPUT_PERSONAL_TOKEN'];
delete process.env['INPUT_PUBLISH_BRANCH'];
delete process.env['INPUT_PUBLISH_DIR'];
delete process.env['INPUT_EXTERNAL_REPOSITORY'];
delete process.env['INPUT_ALLOW_EMPTY_COMMIT'];
delete process.env['INPUT_KEEP_FILES'];
delete process.env['INPUT_FORCE_ORPHAN'];
delete process.env['INPUT_USER_NAME'];
delete process.env['INPUT_USER_EMAIL'];
delete process.env['INPUT_COMMIT_MESSAGE'];
delete process.env['INPUT_TAG_NAME'];
delete process.env['INPUT_TAG_MESSAGE'];
delete process.env['INPUT_DISABLE_NOJEKYLL'];
delete process.env['INPUT_CNAME'];
});
describe('getInputs()', () => {
test('get default inputs', () => {
process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
// process.env['INPUT_GITHUB_TOKEN'] = 'test_github_token';
// process.env['INPUT_PERSONAL_TOKEN'] = 'test_personal_token';
process.env['INPUT_PUBLISH_BRANCH'] = 'gh-pages';
process.env['INPUT_PUBLISH_DIR'] = 'public';
const inps: Inputs = getInputs();
@ -111,7 +40,6 @@ describe('getInputs()', () => {
expect(inps.PersonalToken).toMatch('');
expect(inps.PublishBranch).toMatch('gh-pages');
expect(inps.PublishDir).toMatch('public');
expect(inps.DestinationDir).toMatch('');
expect(inps.ExternalRepository).toMatch('');
expect(inps.AllowEmptyCommit).toBe(false);
expect(inps.KeepFiles).toBe(false);
@ -119,12 +47,10 @@ describe('getInputs()', () => {
expect(inps.UserName).toMatch('');
expect(inps.UserEmail).toMatch('');
expect(inps.CommitMessage).toMatch('');
expect(inps.FullCommitMessage).toMatch('');
expect(inps.TagName).toMatch('');
expect(inps.TagMessage).toMatch('');
expect(inps.DisableNoJekyll).toBe(false);
expect(inps.CNAME).toMatch('');
expect(inps.ExcludeAssets).toMatch('.github');
});
test('get spec inputs', () => {
@ -133,7 +59,6 @@ describe('getInputs()', () => {
process.env['INPUT_PERSONAL_TOKEN'] = 'test_personal_token';
process.env['INPUT_PUBLISH_BRANCH'] = 'master';
process.env['INPUT_PUBLISH_DIR'] = 'out';
process.env['INPUT_DESTINATION_DIR'] = 'subdir';
process.env['INPUT_EXTERNAL_REPOSITORY'] = 'user/repo';
process.env['INPUT_ALLOW_EMPTY_COMMIT'] = 'true';
process.env['INPUT_KEEP_FILES'] = 'true';
@ -141,12 +66,10 @@ describe('getInputs()', () => {
process.env['INPUT_USER_NAME'] = 'username';
process.env['INPUT_USER_EMAIL'] = 'github@github.com';
process.env['INPUT_COMMIT_MESSAGE'] = 'feat: Add new feature';
process.env['INPUT_FULL_COMMIT_MESSAGE'] = 'feat: Add new feature';
process.env['INPUT_TAG_NAME'] = 'deploy-v1.2.3';
process.env['INPUT_TAG_MESSAGE'] = 'Deployment v1.2.3';
process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
process.env['INPUT_CNAME'] = 'github.com';
process.env['INPUT_EXCLUDE_ASSETS'] = '.github';
const inps: Inputs = getInputs();
@ -155,7 +78,6 @@ describe('getInputs()', () => {
expect(inps.PersonalToken).toMatch('test_personal_token');
expect(inps.PublishBranch).toMatch('master');
expect(inps.PublishDir).toMatch('out');
expect(inps.DestinationDir).toMatch('subdir');
expect(inps.ExternalRepository).toMatch('user/repo');
expect(inps.AllowEmptyCommit).toBe(true);
expect(inps.KeepFiles).toBe(true);
@ -163,27 +85,9 @@ describe('getInputs()', () => {
expect(inps.UserName).toMatch('username');
expect(inps.UserEmail).toMatch('github@github.com');
expect(inps.CommitMessage).toMatch('feat: Add new feature');
expect(inps.FullCommitMessage).toMatch('feat: Add new feature');
expect(inps.TagName).toMatch('deploy-v1.2.3');
expect(inps.TagMessage).toMatch('Deployment v1.2.3');
expect(inps.DisableNoJekyll).toBe(true);
expect(inps.CNAME).toMatch('github.com');
expect(inps.ExcludeAssets).toMatch('.github');
});
test('get spec inputs enable_jekyll', () => {
process.env['INPUT_ENABLE_JEKYLL'] = 'true';
const inps: Inputs = getInputs();
expect(inps.DisableNoJekyll).toBe(true);
});
test('throw error enable_jekyll or disable_nojekyll', () => {
process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
process.env['INPUT_ENABLE_JEKYLL'] = 'true';
process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
expect(() => {
getInputs();
}).toThrow('Use either of enable_jekyll or disable_nojekyll');
});
});

View File

@ -1,302 +0,0 @@
import {
copyAssets,
setRepo,
getUserName,
getUserEmail,
setCommitAuthor,
getCommitMessage
} from '../src/git-utils';
import {getInputs} from '../src/get-inputs';
import {Inputs} from '../src/interfaces';
import {getWorkDirName, createDir} from '../src/utils';
import {CmdResult} from '../src/interfaces';
import * as exec from '@actions/exec';
import {cp, rm} from 'shelljs';
import path from 'path';
import fs from 'fs';
const testRoot = path.resolve(__dirname);
async function createTestDir(name: string): Promise<string> {
const date = new Date();
const unixTime = date.getTime();
return await getWorkDirName(`${unixTime}_${name}`);
}
beforeEach(() => {
jest.resetModules();
process.env['GITHUB_ACTOR'] = 'default-octocat';
process.env['GITHUB_REPOSITORY'] = 'owner/repo';
});
afterEach(() => {
delete process.env['GITHUB_ACTOR'];
delete process.env['GITHUB_REPOSITORY'];
});
describe('copyAssets', () => {
let gitTempDir = '';
(async (): Promise<void> => {
const date = new Date();
const unixTime = date.getTime();
gitTempDir = await getWorkDirName(`${unixTime}_git`);
})();
beforeAll(async () => {
await createDir(gitTempDir);
process.chdir(gitTempDir);
await exec.exec('git', ['init']);
});
test('copy assets from publish_dir to root, delete .github', async () => {
const publishDir = await createTestDir('src');
const destDir = await createTestDir('dst');
cp('-Rf', path.resolve(testRoot, 'fixtures/publish_dir_1'), publishDir);
cp('-Rf', gitTempDir, destDir);
await copyAssets(publishDir, destDir, '.github');
expect(fs.existsSync(path.resolve(destDir, '.github'))).toBeFalsy();
expect(fs.existsSync(path.resolve(destDir, 'index.html'))).toBeTruthy();
expect(fs.existsSync(path.resolve(destDir, 'assets/lib.css'))).toBeTruthy();
rm('-rf', publishDir, destDir);
});
test('copy assets from publish_dir to root, delete .github,main.js', async () => {
const publishDir = await createTestDir('src');
const destDir = await createTestDir('dst');
cp('-Rf', path.resolve(testRoot, 'fixtures/publish_dir_1'), publishDir);
cp('-Rf', gitTempDir, destDir);
await copyAssets(publishDir, destDir, '.github,main.js');
expect(fs.existsSync(path.resolve(destDir, '.github'))).toBeFalsy();
expect(fs.existsSync(path.resolve(destDir, 'index.html'))).toBeTruthy();
expect(fs.existsSync(path.resolve(destDir, 'main.js'))).toBeFalsy();
expect(fs.existsSync(path.resolve(destDir, 'assets/lib.css'))).toBeTruthy();
expect(fs.existsSync(path.resolve(destDir, 'assets/lib.js'))).toBeTruthy();
rm('-rf', publishDir, destDir);
});
test('copy assets from publish_dir to root, delete nothing', async () => {
const publishDir = await createTestDir('src');
const destDir = await createTestDir('dst');
cp('-Rf', path.resolve(testRoot, 'fixtures/publish_dir_root'), publishDir);
cp('-Rf', gitTempDir, destDir);
await copyAssets(publishDir, destDir, '');
expect(fs.existsSync(path.resolve(destDir, '.github'))).toBeTruthy();
expect(fs.existsSync(path.resolve(destDir, 'index.html'))).toBeTruthy();
expect(fs.existsSync(path.resolve(destDir, 'main.js'))).toBeTruthy();
expect(fs.existsSync(path.resolve(destDir, 'assets/lib.css'))).toBeTruthy();
expect(fs.existsSync(path.resolve(destDir, 'assets/lib.js'))).toBeTruthy();
rm('-rf', publishDir, destDir);
});
test('copy assets from root to root, delete .github', async () => {
const publishDir = await createTestDir('src');
const destDir = await createTestDir('dst');
cp('-Rf', path.resolve(testRoot, 'fixtures/publish_dir_root'), publishDir);
cp('-Rf', gitTempDir, destDir);
cp('-Rf', gitTempDir, publishDir);
await copyAssets(publishDir, destDir, '.github');
expect(fs.existsSync(path.resolve(destDir, '.github'))).toBeFalsy();
expect(fs.existsSync(path.resolve(destDir, 'index.html'))).toBeTruthy();
expect(fs.existsSync(path.resolve(destDir, 'assets/lib.css'))).toBeTruthy();
rm('-rf', publishDir, destDir);
});
test('copy assets from root to root, delete nothing', async () => {
const publishDir = await createTestDir('src');
const destDir = await createTestDir('dst');
cp('-Rf', path.resolve(testRoot, 'fixtures/publish_dir_root'), publishDir);
cp('-Rf', gitTempDir, destDir);
cp('-Rf', gitTempDir, publishDir);
await copyAssets(publishDir, destDir, '');
expect(fs.existsSync(path.resolve(destDir, '.github'))).toBeTruthy();
expect(fs.existsSync(path.resolve(destDir, 'index.html'))).toBeTruthy();
expect(fs.existsSync(path.resolve(destDir, 'assets/lib.css'))).toBeTruthy();
rm('-rf', publishDir, destDir);
});
test.todo('copy assets from root to subdir, delete .github');
test.todo('copy assets from root to subdir, delete .github,main.js');
test.todo('copy assets from root to subdir, delete nothing');
});
describe('setRepo()', () => {
test('throw error destination_dir should be a relative path', async () => {
process.env['INPUT_GITHUB_TOKEN'] = 'test_github_token';
process.env['INPUT_PUBLISH_BRANCH'] = 'gh-pages';
process.env['INPUT_PUBLISH_DIR'] = 'public';
process.env['INPUT_DESTINATION_DIR'] = '/subdir';
// process.env['INPUT_EXTERNAL_REPOSITORY'] = 'user/repo';
// process.env['INPUT_ALLOW_EMPTY_COMMIT'] = 'true';
// process.env['INPUT_KEEP_FILES'] = 'true';
// process.env['INPUT_FORCE_ORPHAN'] = 'true';
// process.env['INPUT_USER_NAME'] = 'username';
// process.env['INPUT_USER_EMAIL'] = 'github@github.com';
// process.env['INPUT_COMMIT_MESSAGE'] = 'feat: Add new feature';
// process.env['INPUT_FULL_COMMIT_MESSAGE'] = 'feat: Add new feature';
// process.env['INPUT_TAG_NAME'] = 'deploy-v1.2.3';
// process.env['INPUT_TAG_MESSAGE'] = 'Deployment v1.2.3';
// process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
// process.env['INPUT_CNAME'] = 'github.com';
process.env['INPUT_EXCLUDE_ASSETS'] = '.github';
const inps: Inputs = getInputs();
const remoteURL = 'https://x-access-token:pat@github.com/actions/pages.git';
const date = new Date();
const unixTime = date.getTime();
const workDir = await getWorkDirName(`${unixTime}`);
await expect(setRepo(inps, remoteURL, workDir)).rejects.toThrow(
'destination_dir should be a relative path'
);
});
});
describe('getUserName()', () => {
test('get default git user name', () => {
const userName = '';
const test = getUserName(userName);
expect(test).toMatch('default-octocat');
});
test('get custom git user name', () => {
const userName = 'custom-octocat';
const test = getUserName(userName);
expect(test).toMatch(userName);
});
});
describe('getUserEmail()', () => {
test('get default git user email', () => {
const userEmail = '';
const test = getUserEmail(userEmail);
expect(test).toMatch('default-octocat@users.noreply.github.com');
});
test('get custom git user email', () => {
const userEmail = 'custom-octocat@github.com';
const test = getUserEmail(userEmail);
expect(test).toMatch(userEmail);
});
});
describe('setCommitAuthor()', () => {
let workDirName = '';
(async (): Promise<void> => {
const date = new Date();
const unixTime = date.getTime();
workDirName = await getWorkDirName(`${unixTime}`);
})();
beforeEach(async () => {
await createDir(workDirName);
process.chdir(workDirName);
await exec.exec('git', ['init']);
});
test('get default commit author', async () => {
const userName = '';
const userEmail = '';
const result: CmdResult = {
exitcode: 0,
output: ''
};
const options = {
listeners: {
stdout: (data: Buffer): void => {
result.output += data.toString();
}
}
};
await setCommitAuthor(userName, userEmail);
result.exitcode = await exec.exec('git', ['config', 'user.name'], options);
expect(result.output).toMatch('default-octocat');
result.exitcode = await exec.exec('git', ['config', 'user.email'], options);
expect(result.output).toMatch('default-octocat@users.noreply.github.com');
});
test('get custom commit author', async () => {
const userName = 'custom-octocat';
const userEmail = 'custom-octocat@github.com';
const result: CmdResult = {
exitcode: 0,
output: ''
};
const options = {
listeners: {
stdout: (data: Buffer): void => {
result.output += data.toString();
}
}
};
await setCommitAuthor(userName, userEmail);
result.exitcode = await exec.exec('git', ['config', 'user.name'], options);
expect(result.output).toMatch(userName);
result.exitcode = await exec.exec('git', ['config', 'user.email'], options);
expect(result.output).toMatch(userEmail);
});
test('throw error user_email is undefined', async () => {
const userName = 'custom-octocat';
const userEmail = '';
await expect(setCommitAuthor(userName, userEmail)).rejects.toThrow('user_email is undefined');
});
test('throw error user_name is undefined', async () => {
const userName = '';
const userEmail = 'custom-octocat@github.com';
await expect(setCommitAuthor(userName, userEmail)).rejects.toThrow('user_name is undefined');
});
});
describe('getCommitMessage()', () => {
test('get default message', () => {
const test = getCommitMessage('', '', '', 'actions/pages', 'commit_hash');
expect(test).toMatch('deploy: commit_hash');
});
test('get default message for external repository', () => {
const test = getCommitMessage(
'',
'',
'actions/actions.github.io',
'actions/pages',
'commit_hash'
);
expect(test).toMatch('deploy: actions/pages@commit_hash');
});
test('get custom message', () => {
const test = getCommitMessage('Custom msg', '', '', 'actions/pages', 'commit_hash');
expect(test).toMatch('Custom msg commit_hash');
});
test('get custom message for external repository', () => {
const test = getCommitMessage(
'Custom msg',
'',
'actions/actions.github.io',
'actions/pages',
'commit_hash'
);
expect(test).toMatch('Custom msg actions/pages@commit_hash');
});
test('get full custom message', () => {
const test = getCommitMessage('', 'Full custom msg', '', 'actions/pages', 'commit_hash');
expect(test).toMatch('Full custom msg');
});
test('get full custom message for external repository', () => {
const test = getCommitMessage(
'',
'Full custom msg',
'actions/actions.github.io',
'actions/pages',
'commit_hash'
);
expect(test).toMatch('Full custom msg');
});
});

32
__tests__/main.test.ts Normal file
View File

@ -0,0 +1,32 @@
// import {run} from '../src/main';
beforeEach(() => {
jest.resetModules();
});
afterEach(() => {
delete process.env['INPUT_DEPLOY_KEY'];
delete process.env['INPUT_GITHUB_TOKEN'];
delete process.env['INPUT_PERSONAL_TOKEN'];
delete process.env['INPUT_PUBLISH_BRANCH'];
delete process.env['INPUT_PUBLISH_DIR'];
delete process.env['INPUT_EXTERNAL_REPOSITORY'];
delete process.env['INPUT_ALLOW_EMPTY_COMMIT'];
delete process.env['INPUT_KEEP_FILES'];
delete process.env['INPUT_FORCE_ORPHAN'];
delete process.env['INPUT_USER_NAME'];
delete process.env['INPUT_USER_EMAIL'];
delete process.env['INPUT_COMMIT_MESSAGE'];
delete process.env['INPUT_TAG_NAME'];
delete process.env['INPUT_TAG_MESSAGE'];
delete process.env['INPUT_TAG_OVERWRITE'];
});
describe('Integration testing run()', () => {
test('succeed in pushing using deploy key', async () => {
// process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
// process.env['GITHUB_REPOSITORY'] = 'owner/repo';
// const exitcode = await run();
expect(0).toBe(0);
});
});

View File

@ -1,37 +0,0 @@
import {setPersonalToken, setGithubToken} from '../src/set-tokens';
const OLD_ENV = process.env;
beforeEach(() => {
jest.resetModules();
process.env = {...OLD_ENV};
});
afterAll(() => {
process.env = OLD_ENV; // Restore old environment
});
describe('setGithubToken()', () => {
test('return remote url with GITHUB_TOKEN gh-pages', () => {
process.env.GITHUB_SERVER_URL = 'https://github.enterprise.server';
const expected = 'https://x-access-token:GITHUB_TOKEN@github.enterprise.server/owner/repo.git';
const test = setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'gh-pages',
'',
'refs/heads/master',
'push'
);
expect(test).toMatch(expected);
});
});
describe('setPersonalToken()', () => {
test('return remote url with personal access token', () => {
process.env.GITHUB_SERVER_URL = 'https://github.enterprise.server';
const expected = 'https://x-access-token:pat@github.enterprise.server/owner/repo.git';
const test = setPersonalToken('pat', 'owner/repo');
expect(test).toMatch(expected);
});
});

View File

@ -1,118 +0,0 @@
import {getPublishRepo, setPersonalToken, setGithubToken} from '../src/set-tokens';
beforeEach(() => {
jest.resetModules();
});
// afterEach(() => {
// });
describe('getPublishRepo()', () => {
test('return repository name', () => {
const test = getPublishRepo('', 'owner', 'repo');
expect(test).toMatch('owner/repo');
});
test('return external repository name', () => {
const test = getPublishRepo('extOwner/extRepo', 'owner', 'repo');
expect(test).toMatch('extOwner/extRepo');
});
});
describe('setGithubToken()', () => {
test('return remote url with GITHUB_TOKEN gh-pages', () => {
const expected = 'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
const test = setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'gh-pages',
'',
'refs/heads/master',
'push'
);
expect(test).toMatch(expected);
});
test('return remote url with GITHUB_TOKEN master', () => {
const expected = 'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
const test = setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'master',
'',
'refs/heads/source',
'push'
);
expect(test).toMatch(expected);
});
test('return remote url with GITHUB_TOKEN gh-pages (RegExp)', () => {
const expected = 'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
const test = setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'gh-pages',
'',
'refs/heads/gh-pages-base',
'push'
);
expect(test).toMatch(expected);
});
test('throw error gh-pages-base to gh-pages-base (RegExp)', () => {
expect(() => {
setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'gh-pages-base',
'',
'refs/heads/gh-pages-base',
'push'
);
}).toThrow('You deploy from gh-pages-base to gh-pages-base');
});
test('throw error master to master', () => {
expect(() => {
setGithubToken('GITHUB_TOKEN', 'owner/repo', 'master', '', 'refs/heads/master', 'push');
}).toThrow('You deploy from master to master');
});
test('throw error external repository with GITHUB_TOKEN', () => {
expect(() => {
setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'gh-pages',
'extOwner/extRepo',
'refs/heads/master',
'push'
);
}).toThrow(`\
The generated GITHUB_TOKEN (github_token) does not support to push to an external repository.
Use deploy_key or personal_token.
`);
});
test('return remote url with GITHUB_TOKEN pull_request', () => {
const expected = 'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
const test = setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'gh-pages',
'',
'refs/pull/29/merge',
'pull_request'
);
expect(test).toMatch(expected);
});
});
describe('setPersonalToken()', () => {
test('return remote url with personal access token', () => {
const expected = 'https://x-access-token:pat@github.com/owner/repo.git';
const test = setPersonalToken('pat', 'owner/repo');
expect(test).toMatch(expected);
});
});

View File

@ -3,10 +3,9 @@ import fs from 'fs';
import {
getHomeDir,
getWorkDirName,
createDir,
createWorkDir,
addNoJekyll,
addCNAME,
skipOnFork
addCNAME
} from '../src/utils';
beforeEach(() => {
@ -51,11 +50,11 @@ describe('getWorkDirName()', () => {
});
});
describe('createDir()', () => {
test('create a directory', async () => {
describe('createWorkDir()', () => {
test('create work directory', async () => {
const unixTime = await getTime();
const workDirName = await getWorkDirName(`${unixTime}`);
await createDir(workDirName);
await createWorkDir(workDirName);
const test = fs.existsSync(workDirName);
expect(test).toBe(true);
});
@ -65,50 +64,85 @@ async function getWorkDir(): Promise<string> {
const unixTime = await getTime();
let workDir = '';
workDir = await getWorkDirName(`${unixTime}`);
await createDir(workDir);
await createWorkDir(workDir);
return workDir;
}
describe('addNoJekyll()', () => {
test('add .nojekyll', async () => {
test('add .nojekyll gh-pages', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, false);
const test = fs.existsSync(filepath);
expect(test).toBe(true);
await addNoJekyll(workDir, false, 'gh-pages');
const test1 = fs.existsSync(filepath);
expect(test1).toBe(true);
fs.unlinkSync(filepath);
});
test('.nojekyll already exists', async () => {
test('add .nojekyll master', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const filepath = path.join(workDir, '.nojekyll');
fs.closeSync(fs.openSync(filepath, 'w'));
await addNoJekyll(workDir, false);
const test = fs.existsSync(filepath);
expect(test).toBe(true);
await addNoJekyll(workDir, false, 'master');
const test2 = fs.existsSync(filepath);
expect(test2).toBe(true);
fs.unlinkSync(filepath);
});
test('not add .nojekyll disable_nojekyll', async () => {
test('not add .nojekyll disable_nojekyll gh-pages', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, true);
const test = fs.existsSync(filepath);
expect(test).toBe(false);
await addNoJekyll(workDir, true, 'gh-pages');
const test3 = fs.existsSync(filepath);
expect(test3).toBe(false);
});
test('not add .nojekyll disable_nojekyll master', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, true, 'master');
const test4 = fs.existsSync(filepath);
expect(test4).toBe(false);
});
test('not add .nojekyll other-branch', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, false, 'other-branch');
const test5 = fs.existsSync(filepath);
expect(test5).toBe(false);
});
test('not add .nojekyll disable_nojekyll other-branch', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, true, 'other-branch');
const test6 = fs.existsSync(filepath);
expect(test6).toBe(false);
});
});
@ -121,8 +155,8 @@ describe('addCNAME()', () => {
const filepath = path.join(workDir, 'CNAME');
await addCNAME(workDir, 'github.com');
const test = fs.readFileSync(filepath, 'utf8');
expect(test).toMatch('github.com');
const test1 = fs.readFileSync(filepath, 'utf8');
expect(test1).toMatch('github.com');
fs.unlinkSync(filepath);
});
@ -135,8 +169,8 @@ describe('addCNAME()', () => {
const filepath = path.join(workDir, 'CNAME');
await addCNAME(workDir, '');
const test = fs.existsSync(filepath);
expect(test).toBe(false);
const test2 = fs.existsSync(filepath);
expect(test2).toBe(false);
});
test('CNAME already exists', async () => {
@ -148,36 +182,9 @@ describe('addCNAME()', () => {
await addCNAME(workDir, 'github.io');
await addCNAME(workDir, 'github.com');
const test = fs.readFileSync(filepath, 'utf8');
expect(test).toMatch('github.io');
const test3 = fs.readFileSync(filepath, 'utf8');
expect(test3).toMatch('github.io');
fs.unlinkSync(filepath);
});
});
describe('skipOnFork()', () => {
test('return false on upstream', async () => {
const test = await skipOnFork(false, 'token', '', '');
expect(test).toBeFalsy();
});
test('return false on fork with github_token', async () => {
const test = await skipOnFork(true, 'token', '', '');
expect(test).toBeFalsy();
});
test('return false on fork with deploy_key', async () => {
const test = await skipOnFork(true, '', 'deploy_key', '');
expect(test).toBeFalsy();
});
test('return false on fork with personal_token', async () => {
const test = await skipOnFork(true, '', '', 'personal_token');
expect(test).toBeFalsy();
});
test('return true on fork with no tokens', async () => {
const test = await skipOnFork(true, '', '', '');
expect(test).toBeTruthy();
});
});

View File

@ -2,35 +2,31 @@ name: 'GitHub Pages action'
description: 'GitHub Actions for GitHub Pages 🚀 Deploy static files and publish your site easily. Static-Site-Generators-friendly.'
author: 'peaceiris'
runs:
using: 'node20'
using: 'node12'
main: 'lib/index.js'
branding:
icon: 'upload-cloud'
color: 'blue'
inputs:
deploy_key:
description: 'Set a SSH private key from repository secret value for pushing to the remote branch.'
description: ''
required: false
github_token:
description: 'Set a generated GITHUB_TOKEN for pushing to the remote branch.'
description: ''
required: false
personal_token:
description: 'Set a personal access token for pushing to the remote branch.'
description: ''
required: false
publish_branch:
description: 'Set a target branch for deployment.'
description: ''
required: false
default: 'gh-pages'
publish_dir:
description: 'Set an input directory for deployment.'
description: ''
required: false
default: 'public'
destination_dir:
description: 'Set an destination subdirectory for deployment.'
required: false
default: ''
external_repository:
description: 'Set an external repository (owner/repo).'
description: ''
required: false
allow_empty_commit:
description: 'If empty commits should be made to the publication branch'
@ -51,10 +47,7 @@ inputs:
description: 'Set Git user.email'
required: false
commit_message:
description: 'Set a custom commit message with a triggered commit hash'
required: false
full_commit_message:
description: 'Set a custom full commit message without a triggered commit hash'
description: 'Set custom commit message'
required: false
tag_name:
description: 'Set tag name'
@ -62,18 +55,10 @@ inputs:
tag_message:
description: 'Set tag message'
required: false
enable_jekyll:
description: 'Enable the GitHub Pages built-in Jekyll'
required: false
default: 'false'
disable_nojekyll:
description: 'An alias for enable_jekyll to disable adding .nojekyll file to a publishing branch'
description: 'Disable adding .nojekyll file to master or gh-pages branches'
required: false
default: 'false'
cname:
description: 'Set custom domain'
required: false
exclude_assets:
description: 'Set files or directories to exclude from a publish directory.'
required: false
default: '.github'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

BIN
images/default-branch.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
images/log2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
images/log3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

BIN
images/user_repo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -8,4 +8,4 @@ module.exports = {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
};
}

26914
lib/index.js Normal file

File diff suppressed because it is too large Load Diff

15778
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +1,34 @@
{
"name": "actions-github-pages",
"version": "4.0.0",
"version": "3.3.0",
"description": "GitHub Actions for GitHub Pages",
"main": "lib/index.js",
"engines": {
"node": ">=v20.11.0",
"npm": ">=10.2.4"
"node": ">=12.14.1",
"npm": ">=6.13.7"
},
"scripts": {
"postinstall": "npx husky install",
"all": "npm run format && npm run lint && npm test",
"lint": "eslint ./{src,__tests__}/**/*.ts",
"lint:fix": "eslint --fix ./{src,__tests__}/**/*.ts",
"test": "jest --coverage --verbose --detectOpenHandles",
"build": "ncc build ./src/index.ts -o lib --minify",
"build": "ncc build ./src/index.ts -o lib",
"tsc": "tsc",
"format": "prettier --write '**/*.ts'",
"format:check": "prettier --check '**/*.ts'",
"release": "standard-version"
"format": "prettier --write **/*.ts",
"format:check": "prettier --check **/*.ts",
"release": "standard-version",
"update-deps": "(git diff 'HEAD@{1}' --name-only | grep 'package-lock.json' > /dev/null) && npm ci || :"
},
"husky": {
"skipCI": true,
"hooks": {
"pre-commit": "lint-staged",
"post-merge": "npm run update-deps; git remote prune origin"
}
},
"lint-staged": {
"{src,__tests__}/**/*.ts": [
"src/**/*.ts": [
"prettier --check",
"eslint"
],
"README.md": [
"npx doctoc@2.1.0 --github"
]
},
"repository": {
@ -47,33 +50,26 @@
},
"homepage": "https://github.com/peaceiris/actions-gh-pages#readme",
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/github": "^5.1.1",
"@actions/glob": "^0.5.0",
"@actions/io": "^1.1.2",
"@types/shelljs": "^0.8.11",
"shelljs": "^0.8.5"
"@actions/core": "^1.2.2",
"@actions/exec": "^1.0.3",
"@actions/github": "^2.1.1",
"@actions/io": "^1.0.2"
},
"devDependencies": {
"@types/jest": "^29.2.6",
"@types/js-yaml": "^4.0.5",
"@types/node": "~16",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
"@vercel/ncc": "^0.38.0",
"eslint": "^8.32.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3",
"jest": "^29.3.1",
"jest-circus": "^29.3.1",
"js-yaml": "^4.1.0",
"lint-staged": "^13.1.0",
"prettier": "2.8.8",
"standard-version": "^9.1.1",
"ts-jest": "^29.0.5",
"typescript": "^4.9.4"
"@types/jest": "^25.1.3",
"@types/node": "~12",
"@typescript-eslint/eslint-plugin": "^2.20.0",
"@typescript-eslint/parser": "^2.20.0",
"@zeit/ncc": "^0.21.1",
"eslint": "^6.8.0",
"eslint-plugin-jest": "^23.7.0",
"husky": "^4.2.3",
"jest": "^25.1.0",
"jest-circus": "^25.1.0",
"lint-staged": "^10.0.7",
"prettier": "1.19.1",
"standard-version": "^7.1.0",
"ts-jest": "^25.2.1",
"typescript": "^3.8.2"
}
}

View File

@ -3,11 +3,9 @@
# fail on unset variables and command errors
set -eu -o pipefail # -x: is for debugging
DEFAULT_BRANCH="main"
CURRENT_BRANCH="$(git branch --show-current)"
if [ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]; then
echo "$0: Current branch ${CURRENT_BRANCH} is not ${DEFAULT_BRANCH}, continue? (y/n)"
if [ "${CURRENT_BRANCH}" != "master" ]; then
echo "$0: Current branch ${CURRENT_BRANCH} is not master, continue? (y/n)"
read -r res
if [ "${res}" = "n" ]; then
echo "$0: Stop script"
@ -16,7 +14,7 @@ if [ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]; then
fi
PRERELEASE_TYPE_LIST="prerelease prepatch preminor premajor"
if [ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]; then
if [ "${CURRENT_BRANCH}" != "master" ]; then
RELEASE_TYPE_LIST="${PRERELEASE_TYPE_LIST}"
else
RELEASE_TYPE_LIST="${PRERELEASE_TYPE_LIST} patch minor major"
@ -39,15 +37,15 @@ if [ "${res}" = "n" ]; then
fi
git fetch origin
if [ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]; then
if [ "${CURRENT_BRANCH}" != "master" ]; then
git pull origin "${CURRENT_BRANCH}"
else
git pull origin ${DEFAULT_BRANCH}
git pull origin master
git tag -d v3 || true
git pull origin --tags
fi
npm install
npm ci
mkdir ./lib
npm run build
@ -60,10 +58,10 @@ git rm ./lib/index.js
rm -rf ./lib
git commit -m "chore(release): Remove build assets [skip ci]"
if [ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]; then
if [ "${CURRENT_BRANCH}" != "master" ]; then
git push origin "${CURRENT_BRANCH}"
else
git push origin ${DEFAULT_BRANCH}
git push origin master
fi
TAG_NAME="v$(jq -r '.version' ./package.json)"

View File

@ -1,13 +0,0 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>peaceiris/renovate-config"
],
"packageRules": [
{
"automerge": false,
"matchUpdateTypes": ["minor", "patch"],
"automergeStrategy": "squash"
}
]
}

View File

@ -1,74 +1,55 @@
import * as core from '@actions/core';
import {Inputs} from './interfaces';
export function showInputs(inps: Inputs): void {
let authMethod = '';
function showInputs(inps: Inputs): void {
if (inps.DeployKey) {
authMethod = 'DeployKey';
core.info(`[INFO] DeployKey: true`);
} else if (inps.GithubToken) {
authMethod = 'GithubToken';
core.info(`[INFO] GithubToken: true`);
} else if (inps.PersonalToken) {
authMethod = 'PersonalToken';
core.info(`[INFO] PersonalToken: true`);
}
core.info(`\
[INFO] ${authMethod}: true
[INFO] PublishBranch: ${inps.PublishBranch}
[INFO] PublishDir: ${inps.PublishDir}
[INFO] DestinationDir: ${inps.DestinationDir}
[INFO] ExternalRepository: ${inps.ExternalRepository}
[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}
[INFO] KeepFiles: ${inps.KeepFiles}
[INFO] ForceOrphan: ${inps.ForceOrphan}
[INFO] UserName: ${inps.UserName}
[INFO] UserEmail: ${inps.UserEmail}
[INFO] CommitMessage: ${inps.CommitMessage}
[INFO] FullCommitMessage: ${inps.FullCommitMessage}
[INFO] TagName: ${inps.TagName}
[INFO] TagMessage: ${inps.TagMessage}
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
[INFO] CNAME: ${inps.CNAME}
[INFO] ExcludeAssets ${inps.ExcludeAssets}
`);
core.info(`[INFO] PublishBranch: ${inps.PublishBranch}`);
core.info(`[INFO] PublishDir: ${inps.PublishDir}`);
core.info(`[INFO] ExternalRepository: ${inps.ExternalRepository}`);
core.info(`[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}`);
core.info(`[INFO] KeepFiles: ${inps.KeepFiles}`);
core.info(`[INFO] ForceOrphan: ${inps.ForceOrphan}`);
core.info(`[INFO] UserName: ${inps.UserName}`);
core.info(`[INFO] UserEmail: ${inps.UserEmail}`);
core.info(`[INFO] CommitMessage: ${inps.CommitMessage}`);
core.info(`[INFO] TagName: ${inps.TagName}`);
core.info(`[INFO] TagMessage: ${inps.TagMessage}`);
core.info(`[INFO] DisableNoJekyll: ${inps.DisableNoJekyll}`);
core.info(`[INFO] CNAME: ${inps.CNAME}`);
}
export function getInputs(): Inputs {
let useBuiltinJekyll = false;
const isBoolean = (param: string): boolean => (param || 'false').toUpperCase() === 'TRUE';
const enableJekyll: boolean = isBoolean(core.getInput('enable_jekyll'));
const disableNoJekyll: boolean = isBoolean(core.getInput('disable_nojekyll'));
if (enableJekyll && disableNoJekyll) {
throw new Error(`Use either of enable_jekyll or disable_nojekyll`);
} else if (enableJekyll) {
useBuiltinJekyll = true;
} else if (disableNoJekyll) {
useBuiltinJekyll = true;
}
const inps: Inputs = {
DeployKey: core.getInput('deploy_key'),
GithubToken: core.getInput('github_token'),
PersonalToken: core.getInput('personal_token'),
PublishBranch: core.getInput('publish_branch'),
PublishDir: core.getInput('publish_dir'),
DestinationDir: core.getInput('destination_dir'),
ExternalRepository: core.getInput('external_repository'),
AllowEmptyCommit: isBoolean(core.getInput('allow_empty_commit')),
KeepFiles: isBoolean(core.getInput('keep_files')),
ForceOrphan: isBoolean(core.getInput('force_orphan')),
AllowEmptyCommit:
(core.getInput('allow_empty_commit') || 'false').toUpperCase() === 'TRUE',
KeepFiles:
(core.getInput('keep_files') || 'false').toUpperCase() === 'TRUE',
ForceOrphan:
(core.getInput('force_orphan') || 'false').toUpperCase() === 'TRUE',
UserName: core.getInput('user_name'),
UserEmail: core.getInput('user_email'),
CommitMessage: core.getInput('commit_message'),
FullCommitMessage: core.getInput('full_commit_message'),
TagName: core.getInput('tag_name'),
TagMessage: core.getInput('tag_message'),
DisableNoJekyll: useBuiltinJekyll,
CNAME: core.getInput('cname'),
ExcludeAssets: core.getInput('exclude_assets')
DisableNoJekyll:
(core.getInput('disable_nojekyll') || 'false').toUpperCase() === 'TRUE',
CNAME: core.getInput('cname')
};
showInputs(inps);
return inps;
}

View File

@ -1,12 +1,11 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as glob from '@actions/glob';
import * as github from '@actions/github';
import * as io from '@actions/io';
import path from 'path';
import fs from 'fs';
import {URL} from 'url';
import {Inputs, CmdResult} from './interfaces';
import {createDir} from './utils';
import {cp, rm} from 'shelljs';
import {createWorkDir} from './utils';
export async function createBranchForce(branch: string): Promise<void> {
await exec.exec('git', ['init']);
@ -14,79 +13,41 @@ export async function createBranchForce(branch: string): Promise<void> {
return;
}
export function getServerUrl(): URL {
return new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
}
export async function deleteExcludedAssets(destDir: string, excludeAssets: string): Promise<void> {
if (excludeAssets === '') return;
core.info(`[INFO] delete excluded assets`);
const excludedAssetNames: Array<string> = excludeAssets.split(',');
const excludedAssetPaths = ((): Array<string> => {
const paths: Array<string> = [];
for (const pattern of excludedAssetNames) {
paths.push(path.join(destDir, pattern));
}
return paths;
})();
const globber = await glob.create(excludedAssetPaths.join('\n'));
const files = await globber.glob();
for await (const file of globber.globGenerator()) {
core.info(`[INFO] delete ${file}`);
}
rm('-rf', files);
return;
}
export async function copyAssets(
publishDir: string,
destDir: string,
excludeAssets: string
workDir: string
): Promise<void> {
core.info(`[INFO] prepare publishing assets`);
if (!fs.existsSync(destDir)) {
core.info(`[INFO] create ${destDir}`);
await createDir(destDir);
const copyOpts = {recursive: true, force: true};
const files = fs.readdirSync(publishDir);
core.debug(`${files}`);
for await (const file of files) {
if (file.endsWith('.git') || file.endsWith('.github')) {
continue;
}
const filePath = path.join(publishDir, file);
await io.cp(filePath, `${workDir}/`, copyOpts);
core.info(`[INFO] copy ${file}`);
}
const dotGitPath = path.join(publishDir, '.git');
if (fs.existsSync(dotGitPath)) {
core.info(`[INFO] delete ${dotGitPath}`);
rm('-rf', dotGitPath);
}
core.info(`[INFO] copy ${publishDir} to ${destDir}`);
cp('-RfL', [`${publishDir}/*`, `${publishDir}/.*`], destDir);
await deleteExcludedAssets(destDir, excludeAssets);
return;
}
export async function setRepo(inps: Inputs, remoteURL: string, workDir: string): Promise<void> {
const publishDir = path.isAbsolute(inps.PublishDir)
? inps.PublishDir
: path.join(`${process.env.GITHUB_WORKSPACE}`, inps.PublishDir);
if (path.isAbsolute(inps.DestinationDir)) {
throw new Error('destination_dir should be a relative path');
}
const destDir = ((): string => {
if (inps.DestinationDir === '') {
return workDir;
} else {
return path.join(workDir, inps.DestinationDir);
}
})();
export async function setRepo(
inps: Inputs,
remoteURL: string,
workDir: string
): Promise<void> {
const publishDir = path.join(
`${process.env.GITHUB_WORKSPACE}`,
inps.PublishDir
);
core.info(`[INFO] ForceOrphan: ${inps.ForceOrphan}`);
if (inps.ForceOrphan) {
await createDir(destDir);
core.info(`[INFO] chdir ${workDir}`);
await createWorkDir(workDir);
process.chdir(workDir);
await createBranchForce(inps.PublishBranch);
await copyAssets(publishDir, destDir, inps.ExcludeAssets);
await copyAssets(publishDir, workDir);
return;
}
@ -105,117 +66,104 @@ export async function setRepo(inps: Inputs, remoteURL: string, workDir: string):
try {
result.exitcode = await exec.exec(
'git',
['clone', '--depth=1', '--single-branch', '--branch', inps.PublishBranch, remoteURL, workDir],
[
'clone',
'--depth=1',
'--single-branch',
'--branch',
inps.PublishBranch,
remoteURL,
workDir
],
options
);
if (result.exitcode === 0) {
await createDir(destDir);
process.chdir(workDir);
if (inps.KeepFiles) {
core.info('[INFO] Keep existing files');
} else {
core.info(`[INFO] clean up ${destDir}`);
core.info(`[INFO] chdir ${destDir}`);
process.chdir(destDir);
await exec.exec('git', ['rm', '-r', '--ignore-unmatch', '*']);
}
core.info(`[INFO] chdir ${workDir}`);
process.chdir(workDir);
await copyAssets(publishDir, destDir, inps.ExcludeAssets);
await copyAssets(publishDir, workDir);
return;
} else {
throw new Error(`Failed to clone remote branch ${inps.PublishBranch}`);
}
} catch (error) {
if (error instanceof Error) {
core.info(`[INFO] first deployment, create new branch ${inps.PublishBranch}`);
core.info(`[INFO] ${error.message}`);
await createDir(destDir);
core.info(`[INFO] chdir ${workDir}`);
process.chdir(workDir);
await createBranchForce(inps.PublishBranch);
await copyAssets(publishDir, destDir, inps.ExcludeAssets);
return;
} else {
throw new Error('unexpected error');
}
} catch (e) {
core.info(
`[INFO] first deployment, create new branch ${inps.PublishBranch}`
);
core.info(e);
await createWorkDir(workDir);
process.chdir(workDir);
await createBranchForce(inps.PublishBranch);
await copyAssets(publishDir, workDir);
return;
}
}
export function getUserName(userName: string): string {
export async function setConfig(
userName: string,
userEmail: string
): Promise<void> {
await exec.exec('git', ['config', '--global', 'gc.auto', '0']);
let name = '';
if (userName) {
return userName;
name = userName;
} else {
return `${process.env.GITHUB_ACTOR}`;
name = `${process.env.GITHUB_ACTOR}`;
}
}
await exec.exec('git', ['config', '--global', 'user.name', name]);
export function getUserEmail(userEmail: string): string {
if (userEmail) {
return userEmail;
let email = '';
if (userName !== '' && userEmail !== '') {
email = userEmail;
} else {
return `${process.env.GITHUB_ACTOR}@users.noreply.github.com`;
email = `${process.env.GITHUB_ACTOR}@users.noreply.github.com`;
}
await exec.exec('git', ['config', '--global', 'user.email', email]);
return;
}
export async function setCommitAuthor(userName: string, userEmail: string): Promise<void> {
if (userName && !userEmail) {
throw new Error('user_email is undefined');
export async function commit(
allowEmptyCommit: boolean,
externalRepository: string,
message: string
): Promise<void> {
let msg = '';
if (message) {
msg = message;
} else {
msg = 'deploy:';
}
if (!userName && userEmail) {
throw new Error('user_name is undefined');
const hash = `${process.env.GITHUB_SHA}`;
const baseRepo = `${github.context.repo.owner}/${github.context.repo.repo}`;
if (externalRepository) {
msg = `${msg} ${baseRepo}@${hash}`;
} else {
msg = `${msg} ${hash}`;
}
await exec.exec('git', ['config', 'user.name', getUserName(userName)]);
await exec.exec('git', ['config', 'user.email', getUserEmail(userEmail)]);
}
export function getCommitMessage(
msg: string,
fullMsg: string,
extRepo: string,
baseRepo: string,
hash: string
): string {
const msgHash = ((): string => {
if (extRepo) {
return `${baseRepo}@${hash}`;
} else {
return hash;
}
})();
const subject = ((): string => {
if (fullMsg) {
return fullMsg;
} else if (msg) {
return `${msg} ${msgHash}`;
} else {
return `deploy: ${msgHash}`;
}
})();
return subject;
}
export async function commit(allowEmptyCommit: boolean, msg: string): Promise<void> {
try {
if (allowEmptyCommit) {
await exec.exec('git', ['commit', '--allow-empty', '-m', `${msg}`]);
} else {
await exec.exec('git', ['commit', '-m', `${msg}`]);
}
} catch (error) {
if (error instanceof Error) {
core.info('[INFO] skip commit');
core.debug(`[INFO] skip commit ${error.message}`);
} else {
throw new Error('unexpected error');
}
} catch (e) {
core.info('[INFO] skip commit');
core.debug(`[INFO] skip commit ${e}`);
}
}
export async function push(branch: string, forceOrphan: boolean): Promise<void> {
export async function push(
branch: string,
forceOrphan: boolean
): Promise<void> {
if (forceOrphan) {
await exec.exec('git', ['push', 'origin', '--force', branch]);
} else {
@ -223,7 +171,10 @@ export async function push(branch: string, forceOrphan: boolean): Promise<void>
}
}
export async function pushTag(tagName: string, tagMessage: string): Promise<void> {
export async function pushTag(
tagName: string,
tagMessage: string
): Promise<void> {
if (tagName === '') {
return;
}

View File

@ -4,11 +4,7 @@ import * as main from './main';
(async (): Promise<void> => {
try {
await main.run();
} catch (error) {
if (error instanceof Error) {
core.setFailed(`Action failed with "${error.message}"`);
} else {
core.setFailed('unexpected error');
}
} catch (e) {
core.setFailed(`Action failed with "${e}"`);
}
})();

View File

@ -4,7 +4,6 @@ export interface Inputs {
readonly PersonalToken: string;
readonly PublishBranch: string;
readonly PublishDir: string;
readonly DestinationDir: string;
readonly ExternalRepository: string;
readonly AllowEmptyCommit: boolean;
readonly KeepFiles: boolean;
@ -12,12 +11,10 @@ export interface Inputs {
readonly UserName: string;
readonly UserEmail: string;
readonly CommitMessage: string;
readonly FullCommitMessage: string;
readonly TagName: string;
readonly TagMessage: string;
readonly DisableNoJekyll: boolean;
readonly CNAME: string;
readonly ExcludeAssets: string;
}
export interface CmdResult {

View File

@ -1,100 +1,48 @@
import {context} from '@actions/github';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as github from '@actions/github';
import {Inputs} from './interfaces';
import {showInputs, getInputs} from './get-inputs';
import {getInputs} from './get-inputs';
import {setTokens} from './set-tokens';
import {setRepo, setCommitAuthor, getCommitMessage, commit, push, pushTag} from './git-utils';
import {getWorkDirName, addNoJekyll, addCNAME, skipOnFork} from './utils';
import * as git from './git-utils';
import {getWorkDirName, addNoJekyll, addCNAME} from './utils';
export async function run(): Promise<void> {
try {
core.info('[INFO] Usage https://github.com/peaceiris/actions-gh-pages#readme');
const inps: Inputs = getInputs();
core.startGroup('Dump inputs');
showInputs(inps);
core.endGroup();
if (core.isDebug()) {
core.startGroup('Debug: dump context');
console.log(context);
core.endGroup();
}
await git.setConfig(inps.UserName, inps.UserEmail);
const eventName = context.eventName;
if (eventName === 'pull_request' || eventName === 'push') {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const isForkRepository = (context.payload as any).repository.fork;
const isSkipOnFork = await skipOnFork(
isForkRepository,
inps.GithubToken,
inps.DeployKey,
inps.PersonalToken
);
if (isSkipOnFork) {
core.warning('This action runs on a fork and not found auth token, Skip deployment');
core.setOutput('skip', 'true');
return;
}
}
core.startGroup('Setup auth token');
const remoteURL = await setTokens(inps);
core.debug(`remoteURL: ${remoteURL}`);
core.endGroup();
core.debug(`[INFO] remoteURL: ${remoteURL}`);
core.startGroup('Prepare publishing assets');
const date = new Date();
const unixTime = date.getTime();
const workDir = await getWorkDirName(`${unixTime}`);
await setRepo(inps, remoteURL, workDir);
await addNoJekyll(workDir, inps.DisableNoJekyll);
await addCNAME(workDir, inps.CNAME);
core.endGroup();
await git.setRepo(inps, remoteURL, workDir);
await addNoJekyll(workDir, inps.DisableNoJekyll, inps.PublishBranch);
await addCNAME(workDir, inps.CNAME);
core.startGroup('Setup Git config');
try {
await exec.exec('git', ['remote', 'rm', 'origin']);
} catch (error) {
if (error instanceof Error) {
core.info(`[INFO] ${error.message}`);
} else {
throw new Error('unexpected error');
}
} catch (e) {
core.info(`[INFO] ${e}`);
}
await exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
await exec.exec('git', ['add', '--all']);
await setCommitAuthor(inps.UserName, inps.UserEmail);
core.endGroup();
core.startGroup('Create a commit');
const hash = `${process.env.GITHUB_SHA}`;
const baseRepo = `${github.context.repo.owner}/${github.context.repo.repo}`;
const commitMessage = getCommitMessage(
inps.CommitMessage,
inps.FullCommitMessage,
await git.commit(
inps.AllowEmptyCommit,
inps.ExternalRepository,
baseRepo,
hash
inps.CommitMessage
);
await commit(inps.AllowEmptyCommit, commitMessage);
core.endGroup();
core.startGroup('Push the commit or tag');
await push(inps.PublishBranch, inps.ForceOrphan);
await pushTag(inps.TagName, inps.TagMessage);
core.endGroup();
await git.push(inps.PublishBranch, inps.ForceOrphan);
await git.pushTag(inps.TagName, inps.TagMessage);
core.info('[INFO] Action successfully completed');
return;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error('unexpected error');
}
} catch (e) {
throw new Error(e);
}
}

View File

@ -4,15 +4,22 @@ import * as github from '@actions/github';
import * as io from '@actions/io';
import path from 'path';
import fs from 'fs';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const cpSpawnSync = require('child_process').spawnSync;
// eslint-disable-next-line @typescript-eslint/no-var-requires
const cpexec = require('child_process').execFileSync;
import {Inputs} from './interfaces';
import {getHomeDir} from './utils';
import {getServerUrl} from './git-utils';
export async function setSSHKey(inps: Inputs, publishRepo: string): Promise<string> {
export function setPublishRepo(insp: Inputs): string {
if (insp.ExternalRepository) {
return insp.ExternalRepository;
}
return `${github.context.repo.owner}/${github.context.repo.repo}`;
}
export async function setSSHKey(
inps: Inputs,
publishRepo: string
): Promise<string> {
core.info('[INFO] setup SSH deploy key');
const homeDir = await getHomeDir();
@ -21,12 +28,10 @@ export async function setSSHKey(inps: Inputs, publishRepo: string): Promise<stri
await exec.exec('chmod', ['700', sshDir]);
const knownHosts = path.join(sshDir, 'known_hosts');
// ssh-keyscan -t rsa github.com or serverUrl >> ~/.ssh/known_hosts on Ubuntu
// ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts on Ubuntu
const cmdSSHkeyscanOutput = `\
# ${getServerUrl().host}.com:22 SSH-2.0-babeld-1f0633a6
${
getServerUrl().host
} ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=
# github.com:22 SSH-2.0-babeld-1f0633a6
github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
`;
fs.writeFileSync(knownHosts, cmdSSHkeyscanOutput + '\n');
core.info(`[INFO] wrote ${knownHosts}`);
@ -39,8 +44,8 @@ ${
const sshConfigPath = path.join(sshDir, 'config');
const sshConfigContent = `\
Host ${getServerUrl().host}
HostName ${getServerUrl().host}
Host github
HostName github.com
IdentityFile ~/.ssh/github
User git
`;
@ -49,11 +54,6 @@ Host ${getServerUrl().host}
await exec.exec('chmod', ['600', sshConfigPath]);
if (process.platform === 'win32') {
core.warning(`\
Currently, the deploy_key option is not supported on the windows-latest.
Watch https://github.com/peaceiris/actions-gh-pages/issues/87
`);
await cpSpawnSync('Start-Process', ['powershell.exe', '-Verb', 'runas']);
await cpSpawnSync('sh', ['-c', '\'eval "$(ssh-agent)"\''], {shell: true});
await exec.exec('sc', ['config', 'ssh-agent', 'start=auto']);
@ -63,86 +63,60 @@ Watch https://github.com/peaceiris/actions-gh-pages/issues/87
core.exportVariable('SSH_AUTH_SOCK', '/tmp/ssh-auth.sock');
await exec.exec('ssh-add', [idRSA]);
return `git@${getServerUrl().host}:${publishRepo}.git`;
return `git@github.com:${publishRepo}.git`;
}
export function setGithubToken(
githubToken: string,
publishRepo: string,
publishBranch: string,
externalRepository: string,
ref: string,
eventName: string
): string {
export async function setGithubToken(
inps: Inputs,
publishRepo: string
): Promise<string> {
core.info('[INFO] setup GITHUB_TOKEN');
core.debug(`ref: ${ref}`);
core.debug(`eventName: ${eventName}`);
const context = github.context;
core.debug(`ref: ${context.ref}`);
core.debug(`eventName: ${context.eventName}`);
let isProhibitedBranch = false;
if (externalRepository) {
throw new Error(`\
The generated GITHUB_TOKEN (github_token) does not support to push to an external repository.
Use deploy_key or personal_token.
`);
}
if (eventName === 'push') {
isProhibitedBranch = ref.match(new RegExp(`^refs/heads/${publishBranch}$`)) !== null;
const ref = context.ref;
if (context.eventName === 'push') {
isProhibitedBranch = ref.includes(`refs/heads/${inps.PublishBranch}`);
if (isProhibitedBranch) {
throw new Error(`\
You deploy from ${publishBranch} to ${publishBranch}
This operation is prohibited to protect your contents
`);
throw new Error(
`You deploy from ${inps.PublishBranch} to ${inps.PublishBranch}`
);
}
}
return `https://x-access-token:${githubToken}@${getServerUrl().host}/${publishRepo}.git`;
}
export function setPersonalToken(personalToken: string, publishRepo: string): string {
core.info('[INFO] setup personal access token');
return `https://x-access-token:${personalToken}@${getServerUrl().host}/${publishRepo}.git`;
}
export function getPublishRepo(externalRepository: string, owner: string, repo: string): string {
if (externalRepository) {
return externalRepository;
if (inps.ExternalRepository) {
throw new Error(
'GITHUB_TOKEN does not support to push to an external repository'
);
}
return `${owner}/${repo}`;
return `https://x-access-token:${inps.GithubToken}@github.com/${publishRepo}.git`;
}
export async function setPersonalToken(
inps: Inputs,
publishRepo: string
): Promise<string> {
core.info('[INFO] setup personal access token');
return `https://x-access-token:${inps.PersonalToken}@github.com/${publishRepo}.git`;
}
export async function setTokens(inps: Inputs): Promise<string> {
try {
const publishRepo = getPublishRepo(
inps.ExternalRepository,
github.context.repo.owner,
github.context.repo.repo
);
const publishRepo = setPublishRepo(inps);
if (inps.DeployKey) {
return setSSHKey(inps, publishRepo);
} else if (inps.GithubToken) {
const context = github.context;
const ref = context.ref;
const eventName = context.eventName;
return setGithubToken(
inps.GithubToken,
publishRepo,
inps.PublishBranch,
inps.ExternalRepository,
ref,
eventName
);
return setGithubToken(inps, publishRepo);
} else if (inps.PersonalToken) {
return setPersonalToken(inps.PersonalToken, publishRepo);
return setPersonalToken(inps, publishRepo);
} else {
throw new Error('not found deploy key or tokens');
}
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error('unexpected error');
}
} catch (e) {
throw new Error(e);
}
}

View File

@ -23,48 +23,42 @@ export async function getWorkDirName(unixTime: string): Promise<string> {
return workDirName;
}
export async function createDir(dirPath: string): Promise<void> {
await io.mkdirP(dirPath);
core.debug(`Created directory ${dirPath}`);
export async function createWorkDir(workDirName: string): Promise<void> {
await io.mkdirP(workDirName);
core.debug(`Created: ${workDirName}`);
return;
}
export async function addNoJekyll(workDir: string, DisableNoJekyll: boolean): Promise<void> {
export async function addNoJekyll(
workDir: string,
DisableNoJekyll: boolean,
PublishBranch: string
): Promise<void> {
if (DisableNoJekyll) {
return;
}
const filepath = path.join(workDir, '.nojekyll');
if (fs.existsSync(filepath)) {
return;
if (PublishBranch === 'master' || PublishBranch === 'gh-pages') {
const filepath = path.join(workDir, '.nojekyll');
if (fs.existsSync(filepath)) {
return;
}
fs.closeSync(fs.openSync(filepath, 'w'));
core.info(`[INFO] Created ${filepath}`);
}
fs.closeSync(fs.openSync(filepath, 'w'));
core.info(`[INFO] Created ${filepath}`);
}
export async function addCNAME(workDir: string, content: string): Promise<void> {
export async function addCNAME(
workDir: string,
content: string
): Promise<void> {
if (content === '') {
return;
}
const filepath = path.join(workDir, 'CNAME');
if (fs.existsSync(filepath)) {
core.info(`CNAME already exists, skip adding CNAME`);
core.warning(`CNAME already exists, skip adding CNAME`);
return;
}
fs.writeFileSync(filepath, content + '\n');
core.info(`[INFO] Created ${filepath}`);
}
export async function skipOnFork(
isForkRepository: boolean,
githubToken: string,
deployKey: string,
personalToken: string
): Promise<boolean> {
if (isForkRepository) {
if (githubToken === '' && deployKey === '' && personalToken === '') {
return true;
}
}
return false;
}

View File

@ -1,15 +1,64 @@
{
"compilerOptions": {
"lib": ["ES2019"],
"module": "commonjs",
"target": "ES2019",
"sourceMap": true,
"outDir": "./lib",
"rootDir": "./src",
"removeComments": true,
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
"removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
"resolveJsonModule": true
},
"exclude": ["node_modules", "**/*.test.ts"]