Compare commits
No commits in common. "main" and "v3.5.0" have entirely different histories.
9
.dependabot/config.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
version: 1
|
||||||
|
update_configs:
|
||||||
|
- package_manager: "javascript"
|
||||||
|
directory: "/"
|
||||||
|
update_schedule: "daily"
|
||||||
|
default_labels:
|
||||||
|
- "dependencies"
|
||||||
|
commit_message:
|
||||||
|
prefix: "deps"
|
@ -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"
|
|
||||||
}
|
|
@ -6,12 +6,10 @@
|
|||||||
},
|
},
|
||||||
"extends": [
|
"extends": [
|
||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
"plugin:@typescript-eslint/eslint-recommended",
|
|
||||||
"plugin:@typescript-eslint/recommended",
|
"plugin:@typescript-eslint/recommended",
|
||||||
"plugin:jest/recommended",
|
"plugin:@typescript-eslint/recommended",
|
||||||
"plugin:prettier/recommended"
|
"plugin:jest/recommended"
|
||||||
],
|
],
|
||||||
"plugins": ["@typescript-eslint"],
|
|
||||||
"globals": {
|
"globals": {
|
||||||
"Atomics": "readonly",
|
"Atomics": "readonly",
|
||||||
"SharedArrayBuffer": "readonly"
|
"SharedArrayBuffer": "readonly"
|
||||||
|
52
.github/ISSUE_TEMPLATE/1_user_support.yml
vendored
@ -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
|
|
52
.github/ISSUE_TEMPLATE/2_bug_report.txt
vendored
@ -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
|
|
45
.github/ISSUE_TEMPLATE/3_proposal.yml
vendored
@ -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
@ -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.
|
16
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -1,14 +1,8 @@
|
|||||||
blank_issues_enabled: false
|
blank_issues_enabled: false
|
||||||
contact_links:
|
contact_links:
|
||||||
- name: Discussions
|
- name: GitHub Actions Community Forum
|
||||||
url: https://github.com/peaceiris/actions-gh-pages/discussions
|
url: https://github.community/t5/GitHub-Actions/bd-p/actions
|
||||||
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
|
|
||||||
about: Please ask questions about GitHub Actions here.
|
about: Please ask questions about GitHub Actions here.
|
||||||
- name: GitHub Pages Documentation
|
- name: GitHub Pages help
|
||||||
url: https://docs.github.com/en/pages
|
url: https://help.github.com/en/github/working-with-github-pages
|
||||||
about: GitHub Pages official documentation here.
|
about: GitHub Pages documentaion here.
|
||||||
- name: GitHub Actions Documentation
|
|
||||||
url: https://docs.github.com/en/actions
|
|
||||||
about: GitHub Actions official documentation here.
|
|
||||||
|
20
.github/ISSUE_TEMPLATE/proposal.md
vendored
Normal 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.
|
36
.github/label-commenter-config.yml
vendored
@ -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
@ -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
|
|
24
.github/workflows/codeql.yml
vendored
@ -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
|
|
16
.github/workflows/dependency-review.yml
vendored
@ -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
|
|
27
.github/workflows/label-commenter.yml
vendored
@ -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
|
|
22
.github/workflows/labeler.yml
vendored
@ -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 }}"
|
|
2
.github/workflows/pages-status-check.yml
vendored
@ -4,7 +4,7 @@ on: page_build
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pages-status-check:
|
pages-status-check:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
- name: check status
|
- name: check status
|
||||||
run: |
|
run: |
|
||||||
|
@ -3,11 +3,10 @@ name: Purge image cache
|
|||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '54 18 * * */7'
|
- cron: '54 18 * * */7'
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
purge:
|
purge:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- run: >
|
- run: >
|
||||||
|
31
.github/workflows/release.yml
vendored
@ -3,14 +3,35 @@ name: Release
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v3.*.*'
|
- 'v3.*.*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
|
||||||
# https://github.com/peaceiris/workflows/blob/main/create-release-npm/action.yml
|
- uses: actions/checkout@v2
|
||||||
- uses: peaceiris/workflows/create-release-npm@v0.20.1
|
|
||||||
|
- 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:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
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
@ -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
|
113
.github/workflows/test-action.yml
vendored
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
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 i -g npm
|
||||||
|
|
||||||
|
- name: Dump version
|
||||||
|
run: |
|
||||||
|
node -v
|
||||||
|
npm --version
|
||||||
|
git --version
|
||||||
|
|
||||||
|
- 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 }}'
|
171
.github/workflows/test.yml
vendored
@ -3,35 +3,44 @@ name: 'Test'
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- master
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '*.md'
|
- '*.md'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '*.md'
|
- '*.md'
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
skipci:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- run: echo "[Skip CI] ${{ contains(github.event.head_commit.message, '[skip ci]') }}"
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
if: contains(github.event.head_commit.message, '[skip ci]') == false
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- 'ubuntu-22.04'
|
- 'ubuntu-18.04'
|
||||||
- 'ubuntu-20.04'
|
|
||||||
- 'ubuntu-latest'
|
|
||||||
- 'macos-latest'
|
- 'macos-latest'
|
||||||
- 'windows-latest'
|
- 'windows-latest'
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: peaceiris/workflows/setup-node@v0.20.1
|
- name: Read .nvmrc
|
||||||
|
run: echo "::set-output name=NVMRC::$(cat .nvmrc)"
|
||||||
|
id: nvm
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version-file: ".nvmrc"
|
node-version: '${{ steps.nvm.outputs.NVMRC }}'
|
||||||
|
|
||||||
|
- run: npm i -g npm
|
||||||
|
|
||||||
- name: Dump version
|
- name: Dump version
|
||||||
run: |
|
run: |
|
||||||
@ -39,144 +48,28 @@ jobs:
|
|||||||
npm --version
|
npm --version
|
||||||
git --version
|
git --version
|
||||||
|
|
||||||
- run: npm ci --ignore-scripts
|
- run: npm ci
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
- name: Run prettier
|
- name: Run prettier
|
||||||
if: startsWith(matrix.os, 'ubuntu-22.04')
|
if: startsWith(matrix.os, 'ubuntu')
|
||||||
run: npm run format:check
|
run: npm run format:check
|
||||||
|
|
||||||
- name: Run eslint
|
- name: Run eslint
|
||||||
if: startsWith(matrix.os, 'ubuntu-22.04')
|
if: startsWith(matrix.os, 'ubuntu')
|
||||||
run: npm run lint
|
run: npm run lint
|
||||||
|
|
||||||
|
- name: Run ncc
|
||||||
|
if: startsWith(matrix.os, 'ubuntu')
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
- run: npm test
|
- run: npm test
|
||||||
|
|
||||||
- name: Upload test coverage as artifact
|
- name: Upload test coverage as artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: coverage-${{ matrix.os }}
|
name: coverage
|
||||||
path: coverage
|
path: coverage
|
||||||
|
|
||||||
- uses: codecov/codecov-action@v4
|
- uses: codecov/codecov-action@v1
|
||||||
|
|
||||||
- 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
|
|
||||||
with:
|
with:
|
||||||
mdbook-version: '0.4.5'
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
- 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 }}
|
|
||||||
|
27
.github/workflows/update-major-tag.yml
vendored
@ -2,21 +2,22 @@ name: Update major tag
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [released]
|
types: [published]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update:
|
update:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-18.04
|
||||||
timeout-minutes: 1
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Update major tag
|
- uses: actions/checkout@v2
|
||||||
run: |
|
|
||||||
git config user.name "${GITHUB_ACTOR}"
|
- name: Update major tag
|
||||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
if: github.event.release.prerelease == false
|
||||||
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
|
run: |
|
||||||
export TAG_NAME="${GITHUB_REF##refs/tags/}"
|
git config user.name "${GITHUB_ACTOR}"
|
||||||
export TAG_MAJOR="${TAG_NAME%%.*}"
|
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||||
git tag --force -a "${TAG_MAJOR}" -m "Release ${TAG_NAME}"
|
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
|
||||||
git push --force origin "${TAG_MAJOR}"
|
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
@ -1 +0,0 @@
|
|||||||
_
|
|
@ -1,2 +0,0 @@
|
|||||||
npm install
|
|
||||||
git remote prune origin
|
|
@ -1 +0,0 @@
|
|||||||
npx lint-staged
|
|
@ -1,2 +0,0 @@
|
|||||||
node_modules/
|
|
||||||
lib/
|
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"printWidth": 100,
|
"printWidth": 80,
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"useTabs": false,
|
"useTabs": false,
|
||||||
"semi": true,
|
"semi": true,
|
||||||
|
1
.vscode/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
*.log
|
|
3
.vscode/settings.json
vendored
@ -1,4 +1,3 @@
|
|||||||
{
|
{
|
||||||
"git.ignoreLimitWarning": true,
|
"git.ignoreLimitWarning": true
|
||||||
"deno.enable": false
|
|
||||||
}
|
}
|
1159
CHANGELOG.md
31
Dockerfile
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
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/* && \
|
||||||
|
npm i -g npm
|
||||||
|
|
||||||
|
WORKDIR /git
|
||||||
|
ENV GIT_VERSION="2.25.1"
|
||||||
|
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" ]
|
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
23
Makefile
Normal 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)"
|
@ -1 +0,0 @@
|
|||||||
/* CSS */
|
|
@ -1 +0,0 @@
|
|||||||
// JavaScript
|
|
@ -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>
|
|
@ -1 +0,0 @@
|
|||||||
/* CSS */
|
|
@ -1 +0,0 @@
|
|||||||
// JavaScript
|
|
@ -1 +0,0 @@
|
|||||||
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
|
|
@ -1 +0,0 @@
|
|||||||
<!-- issue template -->
|
|
@ -1,7 +0,0 @@
|
|||||||
# dependabot config
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: npm
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: daily
|
|
@ -1 +0,0 @@
|
|||||||
name: 'Test'
|
|
@ -1 +0,0 @@
|
|||||||
/* CSS */
|
|
@ -1 +0,0 @@
|
|||||||
// JavaScript
|
|
@ -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>
|
|
@ -1 +0,0 @@
|
|||||||
/* CSS */
|
|
@ -1 +0,0 @@
|
|||||||
// JavaScript
|
|
@ -9,8 +9,9 @@ beforeEach(() => {
|
|||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
process.stdout.write = jest.fn();
|
process.stdout.write = jest.fn();
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
const doc = yaml.safeLoad(
|
||||||
const doc: any = yaml.load(fs.readFileSync(__dirname + '/../action.yml', 'utf8'));
|
fs.readFileSync(__dirname + '/../action.yml', 'utf8')
|
||||||
|
);
|
||||||
Object.keys(doc.inputs).forEach(name => {
|
Object.keys(doc.inputs).forEach(name => {
|
||||||
const envVar = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
const envVar = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||||
process.env[envVar] = doc.inputs[name]['default'];
|
process.env[envVar] = doc.inputs[name]['default'];
|
||||||
@ -18,8 +19,9 @@ beforeEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
const doc = yaml.safeLoad(
|
||||||
const doc: any = yaml.load(fs.readFileSync(__dirname + '/../action.yml', 'utf8'));
|
fs.readFileSync(__dirname + '/../action.yml', 'utf8')
|
||||||
|
);
|
||||||
Object.keys(doc.inputs).forEach(name => {
|
Object.keys(doc.inputs).forEach(name => {
|
||||||
const envVar = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
const envVar = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||||
console.debug(`delete ${envVar}\t${process.env[envVar]}`);
|
console.debug(`delete ${envVar}\t${process.env[envVar]}`);
|
||||||
@ -42,7 +44,6 @@ function getInputsLog(authMethod: string, inps: Inputs): string {
|
|||||||
[INFO] ${authMethod}: true
|
[INFO] ${authMethod}: true
|
||||||
[INFO] PublishBranch: ${inps.PublishBranch}
|
[INFO] PublishBranch: ${inps.PublishBranch}
|
||||||
[INFO] PublishDir: ${inps.PublishDir}
|
[INFO] PublishDir: ${inps.PublishDir}
|
||||||
[INFO] DestinationDir: ${inps.DestinationDir}
|
|
||||||
[INFO] ExternalRepository: ${inps.ExternalRepository}
|
[INFO] ExternalRepository: ${inps.ExternalRepository}
|
||||||
[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}
|
[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}
|
||||||
[INFO] KeepFiles: ${inps.KeepFiles}
|
[INFO] KeepFiles: ${inps.KeepFiles}
|
||||||
@ -50,12 +51,10 @@ function getInputsLog(authMethod: string, inps: Inputs): string {
|
|||||||
[INFO] UserName: ${inps.UserName}
|
[INFO] UserName: ${inps.UserName}
|
||||||
[INFO] UserEmail: ${inps.UserEmail}
|
[INFO] UserEmail: ${inps.UserEmail}
|
||||||
[INFO] CommitMessage: ${inps.CommitMessage}
|
[INFO] CommitMessage: ${inps.CommitMessage}
|
||||||
[INFO] FullCommitMessage: ${inps.FullCommitMessage}
|
|
||||||
[INFO] TagName: ${inps.TagName}
|
[INFO] TagName: ${inps.TagName}
|
||||||
[INFO] TagMessage: ${inps.TagMessage}
|
[INFO] TagMessage: ${inps.TagMessage}
|
||||||
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
|
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
|
||||||
[INFO] CNAME: ${inps.CNAME}
|
[INFO] CNAME: ${inps.CNAME}
|
||||||
[INFO] ExcludeAssets ${inps.ExcludeAssets}
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +110,6 @@ describe('getInputs()', () => {
|
|||||||
expect(inps.PersonalToken).toMatch('');
|
expect(inps.PersonalToken).toMatch('');
|
||||||
expect(inps.PublishBranch).toMatch('gh-pages');
|
expect(inps.PublishBranch).toMatch('gh-pages');
|
||||||
expect(inps.PublishDir).toMatch('public');
|
expect(inps.PublishDir).toMatch('public');
|
||||||
expect(inps.DestinationDir).toMatch('');
|
|
||||||
expect(inps.ExternalRepository).toMatch('');
|
expect(inps.ExternalRepository).toMatch('');
|
||||||
expect(inps.AllowEmptyCommit).toBe(false);
|
expect(inps.AllowEmptyCommit).toBe(false);
|
||||||
expect(inps.KeepFiles).toBe(false);
|
expect(inps.KeepFiles).toBe(false);
|
||||||
@ -119,12 +117,10 @@ describe('getInputs()', () => {
|
|||||||
expect(inps.UserName).toMatch('');
|
expect(inps.UserName).toMatch('');
|
||||||
expect(inps.UserEmail).toMatch('');
|
expect(inps.UserEmail).toMatch('');
|
||||||
expect(inps.CommitMessage).toMatch('');
|
expect(inps.CommitMessage).toMatch('');
|
||||||
expect(inps.FullCommitMessage).toMatch('');
|
|
||||||
expect(inps.TagName).toMatch('');
|
expect(inps.TagName).toMatch('');
|
||||||
expect(inps.TagMessage).toMatch('');
|
expect(inps.TagMessage).toMatch('');
|
||||||
expect(inps.DisableNoJekyll).toBe(false);
|
expect(inps.DisableNoJekyll).toBe(false);
|
||||||
expect(inps.CNAME).toMatch('');
|
expect(inps.CNAME).toMatch('');
|
||||||
expect(inps.ExcludeAssets).toMatch('.github');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('get spec inputs', () => {
|
test('get spec inputs', () => {
|
||||||
@ -133,7 +129,6 @@ describe('getInputs()', () => {
|
|||||||
process.env['INPUT_PERSONAL_TOKEN'] = 'test_personal_token';
|
process.env['INPUT_PERSONAL_TOKEN'] = 'test_personal_token';
|
||||||
process.env['INPUT_PUBLISH_BRANCH'] = 'master';
|
process.env['INPUT_PUBLISH_BRANCH'] = 'master';
|
||||||
process.env['INPUT_PUBLISH_DIR'] = 'out';
|
process.env['INPUT_PUBLISH_DIR'] = 'out';
|
||||||
process.env['INPUT_DESTINATION_DIR'] = 'subdir';
|
|
||||||
process.env['INPUT_EXTERNAL_REPOSITORY'] = 'user/repo';
|
process.env['INPUT_EXTERNAL_REPOSITORY'] = 'user/repo';
|
||||||
process.env['INPUT_ALLOW_EMPTY_COMMIT'] = 'true';
|
process.env['INPUT_ALLOW_EMPTY_COMMIT'] = 'true';
|
||||||
process.env['INPUT_KEEP_FILES'] = 'true';
|
process.env['INPUT_KEEP_FILES'] = 'true';
|
||||||
@ -141,12 +136,10 @@ describe('getInputs()', () => {
|
|||||||
process.env['INPUT_USER_NAME'] = 'username';
|
process.env['INPUT_USER_NAME'] = 'username';
|
||||||
process.env['INPUT_USER_EMAIL'] = 'github@github.com';
|
process.env['INPUT_USER_EMAIL'] = 'github@github.com';
|
||||||
process.env['INPUT_COMMIT_MESSAGE'] = 'feat: Add new feature';
|
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_NAME'] = 'deploy-v1.2.3';
|
||||||
process.env['INPUT_TAG_MESSAGE'] = 'Deployment v1.2.3';
|
process.env['INPUT_TAG_MESSAGE'] = 'Deployment v1.2.3';
|
||||||
process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
|
process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
|
||||||
process.env['INPUT_CNAME'] = 'github.com';
|
process.env['INPUT_CNAME'] = 'github.com';
|
||||||
process.env['INPUT_EXCLUDE_ASSETS'] = '.github';
|
|
||||||
|
|
||||||
const inps: Inputs = getInputs();
|
const inps: Inputs = getInputs();
|
||||||
|
|
||||||
@ -155,7 +148,6 @@ describe('getInputs()', () => {
|
|||||||
expect(inps.PersonalToken).toMatch('test_personal_token');
|
expect(inps.PersonalToken).toMatch('test_personal_token');
|
||||||
expect(inps.PublishBranch).toMatch('master');
|
expect(inps.PublishBranch).toMatch('master');
|
||||||
expect(inps.PublishDir).toMatch('out');
|
expect(inps.PublishDir).toMatch('out');
|
||||||
expect(inps.DestinationDir).toMatch('subdir');
|
|
||||||
expect(inps.ExternalRepository).toMatch('user/repo');
|
expect(inps.ExternalRepository).toMatch('user/repo');
|
||||||
expect(inps.AllowEmptyCommit).toBe(true);
|
expect(inps.AllowEmptyCommit).toBe(true);
|
||||||
expect(inps.KeepFiles).toBe(true);
|
expect(inps.KeepFiles).toBe(true);
|
||||||
@ -163,18 +155,10 @@ describe('getInputs()', () => {
|
|||||||
expect(inps.UserName).toMatch('username');
|
expect(inps.UserName).toMatch('username');
|
||||||
expect(inps.UserEmail).toMatch('github@github.com');
|
expect(inps.UserEmail).toMatch('github@github.com');
|
||||||
expect(inps.CommitMessage).toMatch('feat: Add new feature');
|
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.TagName).toMatch('deploy-v1.2.3');
|
||||||
expect(inps.TagMessage).toMatch('Deployment v1.2.3');
|
expect(inps.TagMessage).toMatch('Deployment v1.2.3');
|
||||||
expect(inps.DisableNoJekyll).toBe(true);
|
expect(inps.DisableNoJekyll).toBe(true);
|
||||||
expect(inps.CNAME).toMatch('github.com');
|
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', () => {
|
test('throw error enable_jekyll or disable_nojekyll', () => {
|
||||||
@ -184,6 +168,6 @@ describe('getInputs()', () => {
|
|||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
getInputs();
|
getInputs();
|
||||||
}).toThrow('Use either of enable_jekyll or disable_nojekyll');
|
}).toThrowError('Use either of enable_jekyll or disable_nojekyll');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -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');
|
|
||||||
});
|
|
||||||
});
|
|
@ -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);
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,4 +1,8 @@
|
|||||||
import {getPublishRepo, setPersonalToken, setGithubToken} from '../src/set-tokens';
|
import {
|
||||||
|
getPublishRepo,
|
||||||
|
setPersonalToken,
|
||||||
|
setGithubToken
|
||||||
|
} from '../src/set-tokens';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
@ -22,7 +26,8 @@ describe('getPublishRepo()', () => {
|
|||||||
|
|
||||||
describe('setGithubToken()', () => {
|
describe('setGithubToken()', () => {
|
||||||
test('return remote url with GITHUB_TOKEN gh-pages', () => {
|
test('return remote url with GITHUB_TOKEN gh-pages', () => {
|
||||||
const expected = 'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
|
const expected =
|
||||||
|
'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
|
||||||
const test = setGithubToken(
|
const test = setGithubToken(
|
||||||
'GITHUB_TOKEN',
|
'GITHUB_TOKEN',
|
||||||
'owner/repo',
|
'owner/repo',
|
||||||
@ -35,7 +40,8 @@ describe('setGithubToken()', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('return remote url with GITHUB_TOKEN master', () => {
|
test('return remote url with GITHUB_TOKEN master', () => {
|
||||||
const expected = 'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
|
const expected =
|
||||||
|
'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
|
||||||
const test = setGithubToken(
|
const test = setGithubToken(
|
||||||
'GITHUB_TOKEN',
|
'GITHUB_TOKEN',
|
||||||
'owner/repo',
|
'owner/repo',
|
||||||
@ -47,36 +53,17 @@ describe('setGithubToken()', () => {
|
|||||||
expect(test).toMatch(expected);
|
expect(test).toMatch(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('return remote url with GITHUB_TOKEN gh-pages (RegExp)', () => {
|
test('throw error master to master', () => {
|
||||||
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(() => {
|
expect(() => {
|
||||||
setGithubToken(
|
setGithubToken(
|
||||||
'GITHUB_TOKEN',
|
'GITHUB_TOKEN',
|
||||||
'owner/repo',
|
'owner/repo',
|
||||||
'gh-pages-base',
|
'master',
|
||||||
'',
|
'',
|
||||||
'refs/heads/gh-pages-base',
|
'refs/heads/master',
|
||||||
'push'
|
'push'
|
||||||
);
|
);
|
||||||
}).toThrow('You deploy from gh-pages-base to gh-pages-base');
|
}).toThrowError('You deploy from master to master');
|
||||||
});
|
|
||||||
|
|
||||||
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', () => {
|
test('throw error external repository with GITHUB_TOKEN', () => {
|
||||||
@ -89,14 +76,14 @@ describe('setGithubToken()', () => {
|
|||||||
'refs/heads/master',
|
'refs/heads/master',
|
||||||
'push'
|
'push'
|
||||||
);
|
);
|
||||||
}).toThrow(`\
|
}).toThrowError(
|
||||||
The generated GITHUB_TOKEN (github_token) does not support to push to an external repository.
|
'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', () => {
|
test('return remote url with GITHUB_TOKEN pull_request', () => {
|
||||||
const expected = 'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
|
const expected =
|
||||||
|
'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
|
||||||
const test = setGithubToken(
|
const test = setGithubToken(
|
||||||
'GITHUB_TOKEN',
|
'GITHUB_TOKEN',
|
||||||
'owner/repo',
|
'owner/repo',
|
||||||
|
@ -3,10 +3,9 @@ import fs from 'fs';
|
|||||||
import {
|
import {
|
||||||
getHomeDir,
|
getHomeDir,
|
||||||
getWorkDirName,
|
getWorkDirName,
|
||||||
createDir,
|
createWorkDir,
|
||||||
addNoJekyll,
|
addNoJekyll,
|
||||||
addCNAME,
|
addCNAME
|
||||||
skipOnFork
|
|
||||||
} from '../src/utils';
|
} from '../src/utils';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -51,11 +50,11 @@ describe('getWorkDirName()', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('createDir()', () => {
|
describe('createWorkDir()', () => {
|
||||||
test('create a directory', async () => {
|
test('create work directory', async () => {
|
||||||
const unixTime = await getTime();
|
const unixTime = await getTime();
|
||||||
const workDirName = await getWorkDirName(`${unixTime}`);
|
const workDirName = await getWorkDirName(`${unixTime}`);
|
||||||
await createDir(workDirName);
|
await createWorkDir(workDirName);
|
||||||
const test = fs.existsSync(workDirName);
|
const test = fs.existsSync(workDirName);
|
||||||
expect(test).toBe(true);
|
expect(test).toBe(true);
|
||||||
});
|
});
|
||||||
@ -65,19 +64,33 @@ async function getWorkDir(): Promise<string> {
|
|||||||
const unixTime = await getTime();
|
const unixTime = await getTime();
|
||||||
let workDir = '';
|
let workDir = '';
|
||||||
workDir = await getWorkDirName(`${unixTime}`);
|
workDir = await getWorkDirName(`${unixTime}`);
|
||||||
await createDir(workDir);
|
await createWorkDir(workDir);
|
||||||
return workDir;
|
return workDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('addNoJekyll()', () => {
|
describe('addNoJekyll()', () => {
|
||||||
test('add .nojekyll', async () => {
|
test('add .nojekyll gh-pages', async () => {
|
||||||
let workDir = '';
|
let workDir = '';
|
||||||
(async (): Promise<void> => {
|
(async (): Promise<void> => {
|
||||||
workDir = await getWorkDir();
|
workDir = await getWorkDir();
|
||||||
})();
|
})();
|
||||||
const filepath = path.join(workDir, '.nojekyll');
|
const filepath = path.join(workDir, '.nojekyll');
|
||||||
|
|
||||||
await addNoJekyll(workDir, false);
|
await addNoJekyll(workDir, false, 'gh-pages');
|
||||||
|
const test = fs.existsSync(filepath);
|
||||||
|
expect(test).toBe(true);
|
||||||
|
|
||||||
|
fs.unlinkSync(filepath);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('add .nojekyll master', async () => {
|
||||||
|
let workDir = '';
|
||||||
|
(async (): Promise<void> => {
|
||||||
|
workDir = await getWorkDir();
|
||||||
|
})();
|
||||||
|
const filepath = path.join(workDir, '.nojekyll');
|
||||||
|
|
||||||
|
await addNoJekyll(workDir, false, 'master');
|
||||||
const test = fs.existsSync(filepath);
|
const test = fs.existsSync(filepath);
|
||||||
expect(test).toBe(true);
|
expect(test).toBe(true);
|
||||||
|
|
||||||
@ -92,21 +105,57 @@ describe('addNoJekyll()', () => {
|
|||||||
const filepath = path.join(workDir, '.nojekyll');
|
const filepath = path.join(workDir, '.nojekyll');
|
||||||
fs.closeSync(fs.openSync(filepath, 'w'));
|
fs.closeSync(fs.openSync(filepath, 'w'));
|
||||||
|
|
||||||
await addNoJekyll(workDir, false);
|
await addNoJekyll(workDir, false, 'master');
|
||||||
const test = fs.existsSync(filepath);
|
const test = fs.existsSync(filepath);
|
||||||
expect(test).toBe(true);
|
expect(test).toBe(true);
|
||||||
|
|
||||||
fs.unlinkSync(filepath);
|
fs.unlinkSync(filepath);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('not add .nojekyll disable_nojekyll', async () => {
|
test('not add .nojekyll disable_nojekyll gh-pages', async () => {
|
||||||
let workDir = '';
|
let workDir = '';
|
||||||
(async (): Promise<void> => {
|
(async (): Promise<void> => {
|
||||||
workDir = await getWorkDir();
|
workDir = await getWorkDir();
|
||||||
})();
|
})();
|
||||||
const filepath = path.join(workDir, '.nojekyll');
|
const filepath = path.join(workDir, '.nojekyll');
|
||||||
|
|
||||||
await addNoJekyll(workDir, true);
|
await addNoJekyll(workDir, true, 'gh-pages');
|
||||||
|
const test = fs.existsSync(filepath);
|
||||||
|
expect(test).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 test = fs.existsSync(filepath);
|
||||||
|
expect(test).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 test = fs.existsSync(filepath);
|
||||||
|
expect(test).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 test = fs.existsSync(filepath);
|
const test = fs.existsSync(filepath);
|
||||||
expect(test).toBe(false);
|
expect(test).toBe(false);
|
||||||
});
|
});
|
||||||
@ -154,30 +203,3 @@ describe('addCNAME()', () => {
|
|||||||
fs.unlinkSync(filepath);
|
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();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
29
action.yml
@ -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.'
|
description: 'GitHub Actions for GitHub Pages 🚀 Deploy static files and publish your site easily. Static-Site-Generators-friendly.'
|
||||||
author: 'peaceiris'
|
author: 'peaceiris'
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node12'
|
||||||
main: 'lib/index.js'
|
main: 'lib/index.js'
|
||||||
branding:
|
branding:
|
||||||
icon: 'upload-cloud'
|
icon: 'upload-cloud'
|
||||||
color: 'blue'
|
color: 'blue'
|
||||||
inputs:
|
inputs:
|
||||||
deploy_key:
|
deploy_key:
|
||||||
description: 'Set a SSH private key from repository secret value for pushing to the remote branch.'
|
description: ''
|
||||||
required: false
|
required: false
|
||||||
github_token:
|
github_token:
|
||||||
description: 'Set a generated GITHUB_TOKEN for pushing to the remote branch.'
|
description: ''
|
||||||
required: false
|
required: false
|
||||||
personal_token:
|
personal_token:
|
||||||
description: 'Set a personal access token for pushing to the remote branch.'
|
description: ''
|
||||||
required: false
|
required: false
|
||||||
publish_branch:
|
publish_branch:
|
||||||
description: 'Set a target branch for deployment.'
|
description: ''
|
||||||
required: false
|
required: false
|
||||||
default: 'gh-pages'
|
default: 'gh-pages'
|
||||||
publish_dir:
|
publish_dir:
|
||||||
description: 'Set an input directory for deployment.'
|
description: ''
|
||||||
required: false
|
required: false
|
||||||
default: 'public'
|
default: 'public'
|
||||||
destination_dir:
|
|
||||||
description: 'Set an destination subdirectory for deployment.'
|
|
||||||
required: false
|
|
||||||
default: ''
|
|
||||||
external_repository:
|
external_repository:
|
||||||
description: 'Set an external repository (owner/repo).'
|
description: ''
|
||||||
required: false
|
required: false
|
||||||
allow_empty_commit:
|
allow_empty_commit:
|
||||||
description: 'If empty commits should be made to the publication branch'
|
description: 'If empty commits should be made to the publication branch'
|
||||||
@ -51,10 +47,7 @@ inputs:
|
|||||||
description: 'Set Git user.email'
|
description: 'Set Git user.email'
|
||||||
required: false
|
required: false
|
||||||
commit_message:
|
commit_message:
|
||||||
description: 'Set a custom commit message with a triggered commit hash'
|
description: 'Set custom commit message'
|
||||||
required: false
|
|
||||||
full_commit_message:
|
|
||||||
description: 'Set a custom full commit message without a triggered commit hash'
|
|
||||||
required: false
|
required: false
|
||||||
tag_name:
|
tag_name:
|
||||||
description: 'Set tag name'
|
description: 'Set tag name'
|
||||||
@ -67,13 +60,9 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
disable_nojekyll:
|
disable_nojekyll:
|
||||||
description: 'An alias for enable_jekyll to disable adding .nojekyll file to a publishing branch'
|
description: 'An alias for enable_jekyll to disable adding .nojekyll file to master or gh-pages branches'
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
cname:
|
cname:
|
||||||
description: 'Set custom domain'
|
description: 'Set custom domain'
|
||||||
required: false
|
required: false
|
||||||
exclude_assets:
|
|
||||||
description: 'Set files or directories to exclude from a publish directory.'
|
|
||||||
required: false
|
|
||||||
default: '.github'
|
|
||||||
|
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 14 KiB |
BIN
images/default-branch.jpg
Normal file
After Width: | Height: | Size: 43 KiB |
BIN
images/log2.jpg
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
images/log3.jpg
Normal file
After Width: | Height: | Size: 151 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 79 KiB |
BIN
images/user_repo.jpg
Normal file
After Width: | Height: | Size: 54 KiB |
@ -8,4 +8,4 @@ module.exports = {
|
|||||||
'^.+\\.ts$': 'ts-jest'
|
'^.+\\.ts$': 'ts-jest'
|
||||||
},
|
},
|
||||||
verbose: true
|
verbose: true
|
||||||
};
|
}
|
26935
lib/index.js
Normal file
15778
package-lock.json
generated
76
package.json
@ -1,31 +1,34 @@
|
|||||||
{
|
{
|
||||||
"name": "actions-github-pages",
|
"name": "actions-github-pages",
|
||||||
"version": "4.0.0",
|
"version": "3.5.0",
|
||||||
"description": "GitHub Actions for GitHub Pages",
|
"description": "GitHub Actions for GitHub Pages",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=v20.11.0",
|
"node": ">=12.16.1",
|
||||||
"npm": ">=10.2.4"
|
"npm": ">=6.14.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "npx husky install",
|
|
||||||
"all": "npm run format && npm run lint && npm test",
|
|
||||||
"lint": "eslint ./{src,__tests__}/**/*.ts",
|
"lint": "eslint ./{src,__tests__}/**/*.ts",
|
||||||
"lint:fix": "eslint --fix ./{src,__tests__}/**/*.ts",
|
"lint:fix": "eslint --fix ./{src,__tests__}/**/*.ts",
|
||||||
"test": "jest --coverage --verbose --detectOpenHandles",
|
"test": "jest --coverage --verbose --detectOpenHandles",
|
||||||
"build": "ncc build ./src/index.ts -o lib --minify",
|
"build": "ncc build ./src/index.ts -o lib",
|
||||||
"tsc": "tsc",
|
"tsc": "tsc",
|
||||||
"format": "prettier --write '**/*.ts'",
|
"format": "prettier --write **/*.ts",
|
||||||
"format:check": "prettier --check '**/*.ts'",
|
"format:check": "prettier --check **/*.ts",
|
||||||
"release": "standard-version"
|
"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": {
|
"lint-staged": {
|
||||||
"{src,__tests__}/**/*.ts": [
|
"src/**/*.ts": [
|
||||||
"prettier --check",
|
"prettier --check",
|
||||||
"eslint"
|
"eslint"
|
||||||
],
|
|
||||||
"README.md": [
|
|
||||||
"npx doctoc@2.1.0 --github"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -47,33 +50,28 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/peaceiris/actions-gh-pages#readme",
|
"homepage": "https://github.com/peaceiris/actions-gh-pages#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.2.3",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.0.3",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^2.1.1",
|
||||||
"@actions/glob": "^0.5.0",
|
"@actions/io": "^1.0.2"
|
||||||
"@actions/io": "^1.1.2",
|
|
||||||
"@types/shelljs": "^0.8.11",
|
|
||||||
"shelljs": "^0.8.5"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.2.6",
|
"@types/jest": "^25.1.3",
|
||||||
"@types/js-yaml": "^4.0.5",
|
"@types/js-yaml": "^3.12.2",
|
||||||
"@types/node": "~16",
|
"@types/node": "~12",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.48.2",
|
"@typescript-eslint/eslint-plugin": "^2.22.0",
|
||||||
"@typescript-eslint/parser": "^5.48.2",
|
"@typescript-eslint/parser": "^2.22.0",
|
||||||
"@vercel/ncc": "^0.38.0",
|
"@zeit/ncc": "^0.21.1",
|
||||||
"eslint": "^8.32.0",
|
"eslint": "^6.8.0",
|
||||||
"eslint-config-prettier": "^9.0.0",
|
"eslint-plugin-jest": "^23.8.2",
|
||||||
"eslint-plugin-jest": "^27.2.1",
|
"husky": "^4.2.3",
|
||||||
"eslint-plugin-prettier": "^4.2.1",
|
"jest": "^25.1.0",
|
||||||
"husky": "^8.0.3",
|
"jest-circus": "^25.1.0",
|
||||||
"jest": "^29.3.1",
|
"js-yaml": "^3.13.1",
|
||||||
"jest-circus": "^29.3.1",
|
"lint-staged": "^10.0.8",
|
||||||
"js-yaml": "^4.1.0",
|
"prettier": "1.19.1",
|
||||||
"lint-staged": "^13.1.0",
|
"standard-version": "^7.1.0",
|
||||||
"prettier": "2.8.8",
|
"ts-jest": "^25.2.1",
|
||||||
"standard-version": "^9.1.1",
|
"typescript": "^3.8.3"
|
||||||
"ts-jest": "^29.0.5",
|
|
||||||
"typescript": "^4.9.4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
release.sh
@ -3,11 +3,9 @@
|
|||||||
# fail on unset variables and command errors
|
# fail on unset variables and command errors
|
||||||
set -eu -o pipefail # -x: is for debugging
|
set -eu -o pipefail # -x: is for debugging
|
||||||
|
|
||||||
DEFAULT_BRANCH="main"
|
|
||||||
|
|
||||||
CURRENT_BRANCH="$(git branch --show-current)"
|
CURRENT_BRANCH="$(git branch --show-current)"
|
||||||
if [ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]; then
|
if [ "${CURRENT_BRANCH}" != "master" ]; then
|
||||||
echo "$0: Current branch ${CURRENT_BRANCH} is not ${DEFAULT_BRANCH}, continue? (y/n)"
|
echo "$0: Current branch ${CURRENT_BRANCH} is not master, continue? (y/n)"
|
||||||
read -r res
|
read -r res
|
||||||
if [ "${res}" = "n" ]; then
|
if [ "${res}" = "n" ]; then
|
||||||
echo "$0: Stop script"
|
echo "$0: Stop script"
|
||||||
@ -16,7 +14,7 @@ if [ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
PRERELEASE_TYPE_LIST="prerelease prepatch preminor premajor"
|
PRERELEASE_TYPE_LIST="prerelease prepatch preminor premajor"
|
||||||
if [ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]; then
|
if [ "${CURRENT_BRANCH}" != "master" ]; then
|
||||||
RELEASE_TYPE_LIST="${PRERELEASE_TYPE_LIST}"
|
RELEASE_TYPE_LIST="${PRERELEASE_TYPE_LIST}"
|
||||||
else
|
else
|
||||||
RELEASE_TYPE_LIST="${PRERELEASE_TYPE_LIST} patch minor major"
|
RELEASE_TYPE_LIST="${PRERELEASE_TYPE_LIST} patch minor major"
|
||||||
@ -39,15 +37,15 @@ if [ "${res}" = "n" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
git fetch origin
|
git fetch origin
|
||||||
if [ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]; then
|
if [ "${CURRENT_BRANCH}" != "master" ]; then
|
||||||
git pull origin "${CURRENT_BRANCH}"
|
git pull origin "${CURRENT_BRANCH}"
|
||||||
else
|
else
|
||||||
git pull origin ${DEFAULT_BRANCH}
|
git pull origin master
|
||||||
git tag -d v3 || true
|
git tag -d v3 || true
|
||||||
git pull origin --tags
|
git pull origin --tags
|
||||||
fi
|
fi
|
||||||
|
|
||||||
npm install
|
npm ci
|
||||||
|
|
||||||
mkdir ./lib
|
mkdir ./lib
|
||||||
npm run build
|
npm run build
|
||||||
@ -60,10 +58,10 @@ git rm ./lib/index.js
|
|||||||
rm -rf ./lib
|
rm -rf ./lib
|
||||||
git commit -m "chore(release): Remove build assets [skip ci]"
|
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}"
|
git push origin "${CURRENT_BRANCH}"
|
||||||
else
|
else
|
||||||
git push origin ${DEFAULT_BRANCH}
|
git push origin master
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TAG_NAME="v$(jq -r '.version' ./package.json)"
|
TAG_NAME="v$(jq -r '.version' ./package.json)"
|
||||||
|
@ -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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -15,7 +15,6 @@ export function showInputs(inps: Inputs): void {
|
|||||||
[INFO] ${authMethod}: true
|
[INFO] ${authMethod}: true
|
||||||
[INFO] PublishBranch: ${inps.PublishBranch}
|
[INFO] PublishBranch: ${inps.PublishBranch}
|
||||||
[INFO] PublishDir: ${inps.PublishDir}
|
[INFO] PublishDir: ${inps.PublishDir}
|
||||||
[INFO] DestinationDir: ${inps.DestinationDir}
|
|
||||||
[INFO] ExternalRepository: ${inps.ExternalRepository}
|
[INFO] ExternalRepository: ${inps.ExternalRepository}
|
||||||
[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}
|
[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}
|
||||||
[INFO] KeepFiles: ${inps.KeepFiles}
|
[INFO] KeepFiles: ${inps.KeepFiles}
|
||||||
@ -23,22 +22,20 @@ export function showInputs(inps: Inputs): void {
|
|||||||
[INFO] UserName: ${inps.UserName}
|
[INFO] UserName: ${inps.UserName}
|
||||||
[INFO] UserEmail: ${inps.UserEmail}
|
[INFO] UserEmail: ${inps.UserEmail}
|
||||||
[INFO] CommitMessage: ${inps.CommitMessage}
|
[INFO] CommitMessage: ${inps.CommitMessage}
|
||||||
[INFO] FullCommitMessage: ${inps.FullCommitMessage}
|
|
||||||
[INFO] TagName: ${inps.TagName}
|
[INFO] TagName: ${inps.TagName}
|
||||||
[INFO] TagMessage: ${inps.TagMessage}
|
[INFO] TagMessage: ${inps.TagMessage}
|
||||||
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
|
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
|
||||||
[INFO] CNAME: ${inps.CNAME}
|
[INFO] CNAME: ${inps.CNAME}
|
||||||
[INFO] ExcludeAssets ${inps.ExcludeAssets}
|
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getInputs(): Inputs {
|
export function getInputs(): Inputs {
|
||||||
let useBuiltinJekyll = false;
|
let useBuiltinJekyll = false;
|
||||||
|
|
||||||
const isBoolean = (param: string): boolean => (param || 'false').toUpperCase() === 'TRUE';
|
const enableJekyll: boolean =
|
||||||
|
(core.getInput('enable_jekyll') || 'false').toUpperCase() === 'TRUE';
|
||||||
const enableJekyll: boolean = isBoolean(core.getInput('enable_jekyll'));
|
const disableNoJekyll: boolean =
|
||||||
const disableNoJekyll: boolean = isBoolean(core.getInput('disable_nojekyll'));
|
(core.getInput('disable_nojekyll') || 'false').toUpperCase() === 'TRUE';
|
||||||
|
|
||||||
if (enableJekyll && disableNoJekyll) {
|
if (enableJekyll && disableNoJekyll) {
|
||||||
throw new Error(`Use either of enable_jekyll or disable_nojekyll`);
|
throw new Error(`Use either of enable_jekyll or disable_nojekyll`);
|
||||||
@ -54,20 +51,20 @@ export function getInputs(): Inputs {
|
|||||||
PersonalToken: core.getInput('personal_token'),
|
PersonalToken: core.getInput('personal_token'),
|
||||||
PublishBranch: core.getInput('publish_branch'),
|
PublishBranch: core.getInput('publish_branch'),
|
||||||
PublishDir: core.getInput('publish_dir'),
|
PublishDir: core.getInput('publish_dir'),
|
||||||
DestinationDir: core.getInput('destination_dir'),
|
|
||||||
ExternalRepository: core.getInput('external_repository'),
|
ExternalRepository: core.getInput('external_repository'),
|
||||||
AllowEmptyCommit: isBoolean(core.getInput('allow_empty_commit')),
|
AllowEmptyCommit:
|
||||||
KeepFiles: isBoolean(core.getInput('keep_files')),
|
(core.getInput('allow_empty_commit') || 'false').toUpperCase() === 'TRUE',
|
||||||
ForceOrphan: isBoolean(core.getInput('force_orphan')),
|
KeepFiles:
|
||||||
|
(core.getInput('keep_files') || 'false').toUpperCase() === 'TRUE',
|
||||||
|
ForceOrphan:
|
||||||
|
(core.getInput('force_orphan') || 'false').toUpperCase() === 'TRUE',
|
||||||
UserName: core.getInput('user_name'),
|
UserName: core.getInput('user_name'),
|
||||||
UserEmail: core.getInput('user_email'),
|
UserEmail: core.getInput('user_email'),
|
||||||
CommitMessage: core.getInput('commit_message'),
|
CommitMessage: core.getInput('commit_message'),
|
||||||
FullCommitMessage: core.getInput('full_commit_message'),
|
|
||||||
TagName: core.getInput('tag_name'),
|
TagName: core.getInput('tag_name'),
|
||||||
TagMessage: core.getInput('tag_message'),
|
TagMessage: core.getInput('tag_message'),
|
||||||
DisableNoJekyll: useBuiltinJekyll,
|
DisableNoJekyll: useBuiltinJekyll,
|
||||||
CNAME: core.getInput('cname'),
|
CNAME: core.getInput('cname')
|
||||||
ExcludeAssets: core.getInput('exclude_assets')
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return inps;
|
return inps;
|
||||||
|
231
src/git-utils.ts
@ -1,12 +1,11 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
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 path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import {URL} from 'url';
|
|
||||||
import {Inputs, CmdResult} from './interfaces';
|
import {Inputs, CmdResult} from './interfaces';
|
||||||
import {createDir} from './utils';
|
import {createWorkDir} from './utils';
|
||||||
import {cp, rm} from 'shelljs';
|
|
||||||
|
|
||||||
export async function createBranchForce(branch: string): Promise<void> {
|
export async function createBranchForce(branch: string): Promise<void> {
|
||||||
await exec.exec('git', ['init']);
|
await exec.exec('git', ['init']);
|
||||||
@ -14,79 +13,41 @@ export async function createBranchForce(branch: string): Promise<void> {
|
|||||||
return;
|
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(
|
export async function copyAssets(
|
||||||
publishDir: string,
|
publishDir: string,
|
||||||
destDir: string,
|
workDir: string
|
||||||
excludeAssets: string
|
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
core.info(`[INFO] prepare publishing assets`);
|
const copyOpts = {recursive: true, force: true};
|
||||||
|
const files = fs.readdirSync(publishDir);
|
||||||
if (!fs.existsSync(destDir)) {
|
core.debug(`${files}`);
|
||||||
core.info(`[INFO] create ${destDir}`);
|
for await (const file of files) {
|
||||||
await createDir(destDir);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setRepo(inps: Inputs, remoteURL: string, workDir: string): Promise<void> {
|
export async function setRepo(
|
||||||
const publishDir = path.isAbsolute(inps.PublishDir)
|
inps: Inputs,
|
||||||
? inps.PublishDir
|
remoteURL: string,
|
||||||
: path.join(`${process.env.GITHUB_WORKSPACE}`, inps.PublishDir);
|
workDir: string
|
||||||
|
): Promise<void> {
|
||||||
if (path.isAbsolute(inps.DestinationDir)) {
|
const publishDir = path.join(
|
||||||
throw new Error('destination_dir should be a relative path');
|
`${process.env.GITHUB_WORKSPACE}`,
|
||||||
}
|
inps.PublishDir
|
||||||
const destDir = ((): string => {
|
);
|
||||||
if (inps.DestinationDir === '') {
|
|
||||||
return workDir;
|
|
||||||
} else {
|
|
||||||
return path.join(workDir, inps.DestinationDir);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
core.info(`[INFO] ForceOrphan: ${inps.ForceOrphan}`);
|
core.info(`[INFO] ForceOrphan: ${inps.ForceOrphan}`);
|
||||||
if (inps.ForceOrphan) {
|
if (inps.ForceOrphan) {
|
||||||
await createDir(destDir);
|
await createWorkDir(workDir);
|
||||||
core.info(`[INFO] chdir ${workDir}`);
|
|
||||||
process.chdir(workDir);
|
process.chdir(workDir);
|
||||||
await createBranchForce(inps.PublishBranch);
|
await createBranchForce(inps.PublishBranch);
|
||||||
await copyAssets(publishDir, destDir, inps.ExcludeAssets);
|
await copyAssets(publishDir, workDir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,117 +66,104 @@ export async function setRepo(inps: Inputs, remoteURL: string, workDir: string):
|
|||||||
try {
|
try {
|
||||||
result.exitcode = await exec.exec(
|
result.exitcode = await exec.exec(
|
||||||
'git',
|
'git',
|
||||||
['clone', '--depth=1', '--single-branch', '--branch', inps.PublishBranch, remoteURL, workDir],
|
[
|
||||||
|
'clone',
|
||||||
|
'--depth=1',
|
||||||
|
'--single-branch',
|
||||||
|
'--branch',
|
||||||
|
inps.PublishBranch,
|
||||||
|
remoteURL,
|
||||||
|
workDir
|
||||||
|
],
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
if (result.exitcode === 0) {
|
if (result.exitcode === 0) {
|
||||||
await createDir(destDir);
|
process.chdir(workDir);
|
||||||
|
|
||||||
if (inps.KeepFiles) {
|
if (inps.KeepFiles) {
|
||||||
core.info('[INFO] Keep existing files');
|
core.info('[INFO] Keep existing files');
|
||||||
} else {
|
} else {
|
||||||
core.info(`[INFO] clean up ${destDir}`);
|
|
||||||
core.info(`[INFO] chdir ${destDir}`);
|
|
||||||
process.chdir(destDir);
|
|
||||||
await exec.exec('git', ['rm', '-r', '--ignore-unmatch', '*']);
|
await exec.exec('git', ['rm', '-r', '--ignore-unmatch', '*']);
|
||||||
}
|
}
|
||||||
|
|
||||||
core.info(`[INFO] chdir ${workDir}`);
|
await copyAssets(publishDir, workDir);
|
||||||
process.chdir(workDir);
|
|
||||||
await copyAssets(publishDir, destDir, inps.ExcludeAssets);
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Failed to clone remote branch ${inps.PublishBranch}`);
|
throw new Error(`Failed to clone remote branch ${inps.PublishBranch}`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (e) {
|
||||||
if (error instanceof Error) {
|
core.info(
|
||||||
core.info(`[INFO] first deployment, create new branch ${inps.PublishBranch}`);
|
`[INFO] first deployment, create new branch ${inps.PublishBranch}`
|
||||||
core.info(`[INFO] ${error.message}`);
|
);
|
||||||
await createDir(destDir);
|
core.info(e.message);
|
||||||
core.info(`[INFO] chdir ${workDir}`);
|
await createWorkDir(workDir);
|
||||||
process.chdir(workDir);
|
process.chdir(workDir);
|
||||||
await createBranchForce(inps.PublishBranch);
|
await createBranchForce(inps.PublishBranch);
|
||||||
await copyAssets(publishDir, destDir, inps.ExcludeAssets);
|
await copyAssets(publishDir, workDir);
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
throw new Error('unexpected error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
if (userName) {
|
||||||
return userName;
|
name = userName;
|
||||||
} else {
|
} 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 {
|
let email = '';
|
||||||
if (userEmail) {
|
if (userName !== '' && userEmail !== '') {
|
||||||
return userEmail;
|
email = userEmail;
|
||||||
} else {
|
} 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> {
|
export async function commit(
|
||||||
if (userName && !userEmail) {
|
allowEmptyCommit: boolean,
|
||||||
throw new Error('user_email is undefined');
|
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 {
|
try {
|
||||||
if (allowEmptyCommit) {
|
if (allowEmptyCommit) {
|
||||||
await exec.exec('git', ['commit', '--allow-empty', '-m', `${msg}`]);
|
await exec.exec('git', ['commit', '--allow-empty', '-m', `${msg}`]);
|
||||||
} else {
|
} else {
|
||||||
await exec.exec('git', ['commit', '-m', `${msg}`]);
|
await exec.exec('git', ['commit', '-m', `${msg}`]);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (e) {
|
||||||
if (error instanceof Error) {
|
core.info('[INFO] skip commit');
|
||||||
core.info('[INFO] skip commit');
|
core.debug(`[INFO] skip commit ${e.message}`);
|
||||||
core.debug(`[INFO] skip commit ${error.message}`);
|
|
||||||
} else {
|
|
||||||
throw new Error('unexpected error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function push(branch: string, forceOrphan: boolean): Promise<void> {
|
export async function push(
|
||||||
|
branch: string,
|
||||||
|
forceOrphan: boolean
|
||||||
|
): Promise<void> {
|
||||||
if (forceOrphan) {
|
if (forceOrphan) {
|
||||||
await exec.exec('git', ['push', 'origin', '--force', branch]);
|
await exec.exec('git', ['push', 'origin', '--force', branch]);
|
||||||
} else {
|
} 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 === '') {
|
if (tagName === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,7 @@ import * as main from './main';
|
|||||||
(async (): Promise<void> => {
|
(async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
await main.run();
|
await main.run();
|
||||||
} catch (error) {
|
} catch (e) {
|
||||||
if (error instanceof Error) {
|
core.setFailed(`Action failed with "${e.message}"`);
|
||||||
core.setFailed(`Action failed with "${error.message}"`);
|
|
||||||
} else {
|
|
||||||
core.setFailed('unexpected error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
@ -4,7 +4,6 @@ export interface Inputs {
|
|||||||
readonly PersonalToken: string;
|
readonly PersonalToken: string;
|
||||||
readonly PublishBranch: string;
|
readonly PublishBranch: string;
|
||||||
readonly PublishDir: string;
|
readonly PublishDir: string;
|
||||||
readonly DestinationDir: string;
|
|
||||||
readonly ExternalRepository: string;
|
readonly ExternalRepository: string;
|
||||||
readonly AllowEmptyCommit: boolean;
|
readonly AllowEmptyCommit: boolean;
|
||||||
readonly KeepFiles: boolean;
|
readonly KeepFiles: boolean;
|
||||||
@ -12,12 +11,10 @@ export interface Inputs {
|
|||||||
readonly UserName: string;
|
readonly UserName: string;
|
||||||
readonly UserEmail: string;
|
readonly UserEmail: string;
|
||||||
readonly CommitMessage: string;
|
readonly CommitMessage: string;
|
||||||
readonly FullCommitMessage: string;
|
|
||||||
readonly TagName: string;
|
readonly TagName: string;
|
||||||
readonly TagMessage: string;
|
readonly TagMessage: string;
|
||||||
readonly DisableNoJekyll: boolean;
|
readonly DisableNoJekyll: boolean;
|
||||||
readonly CNAME: string;
|
readonly CNAME: string;
|
||||||
readonly ExcludeAssets: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CmdResult {
|
export interface CmdResult {
|
||||||
|
85
src/main.ts
@ -1,100 +1,49 @@
|
|||||||
import {context} from '@actions/github';
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import * as github from '@actions/github';
|
|
||||||
import {Inputs} from './interfaces';
|
import {Inputs} from './interfaces';
|
||||||
import {showInputs, getInputs} from './get-inputs';
|
import {showInputs, getInputs} from './get-inputs';
|
||||||
import {setTokens} from './set-tokens';
|
import {setTokens} from './set-tokens';
|
||||||
import {setRepo, setCommitAuthor, getCommitMessage, commit, push, pushTag} from './git-utils';
|
import * as git from './git-utils';
|
||||||
import {getWorkDirName, addNoJekyll, addCNAME, skipOnFork} from './utils';
|
import {getWorkDirName, addNoJekyll, addCNAME} from './utils';
|
||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
core.info('[INFO] Usage https://github.com/peaceiris/actions-gh-pages#readme');
|
|
||||||
|
|
||||||
const inps: Inputs = getInputs();
|
const inps: Inputs = getInputs();
|
||||||
core.startGroup('Dump inputs');
|
|
||||||
showInputs(inps);
|
showInputs(inps);
|
||||||
core.endGroup();
|
|
||||||
|
|
||||||
if (core.isDebug()) {
|
await git.setConfig(inps.UserName, inps.UserEmail);
|
||||||
core.startGroup('Debug: dump context');
|
|
||||||
console.log(context);
|
|
||||||
core.endGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
const remoteURL = await setTokens(inps);
|
||||||
core.debug(`remoteURL: ${remoteURL}`);
|
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
||||||
core.endGroup();
|
|
||||||
|
|
||||||
core.startGroup('Prepare publishing assets');
|
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const unixTime = date.getTime();
|
const unixTime = date.getTime();
|
||||||
const workDir = await getWorkDirName(`${unixTime}`);
|
const workDir = await getWorkDirName(`${unixTime}`);
|
||||||
await setRepo(inps, remoteURL, workDir);
|
await git.setRepo(inps, remoteURL, workDir);
|
||||||
await addNoJekyll(workDir, inps.DisableNoJekyll);
|
|
||||||
await addCNAME(workDir, inps.CNAME);
|
await addNoJekyll(workDir, inps.DisableNoJekyll, inps.PublishBranch);
|
||||||
core.endGroup();
|
await addCNAME(workDir, inps.CNAME);
|
||||||
|
|
||||||
core.startGroup('Setup Git config');
|
|
||||||
try {
|
try {
|
||||||
await exec.exec('git', ['remote', 'rm', 'origin']);
|
await exec.exec('git', ['remote', 'rm', 'origin']);
|
||||||
} catch (error) {
|
} catch (e) {
|
||||||
if (error instanceof Error) {
|
core.info(`[INFO] ${e.message}`);
|
||||||
core.info(`[INFO] ${error.message}`);
|
|
||||||
} else {
|
|
||||||
throw new Error('unexpected error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
await exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
|
await exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
|
||||||
await exec.exec('git', ['add', '--all']);
|
await exec.exec('git', ['add', '--all']);
|
||||||
await setCommitAuthor(inps.UserName, inps.UserEmail);
|
|
||||||
core.endGroup();
|
|
||||||
|
|
||||||
core.startGroup('Create a commit');
|
await git.commit(
|
||||||
const hash = `${process.env.GITHUB_SHA}`;
|
inps.AllowEmptyCommit,
|
||||||
const baseRepo = `${github.context.repo.owner}/${github.context.repo.repo}`;
|
|
||||||
const commitMessage = getCommitMessage(
|
|
||||||
inps.CommitMessage,
|
|
||||||
inps.FullCommitMessage,
|
|
||||||
inps.ExternalRepository,
|
inps.ExternalRepository,
|
||||||
baseRepo,
|
inps.CommitMessage
|
||||||
hash
|
|
||||||
);
|
);
|
||||||
await commit(inps.AllowEmptyCommit, commitMessage);
|
await git.push(inps.PublishBranch, inps.ForceOrphan);
|
||||||
core.endGroup();
|
await git.pushTag(inps.TagName, inps.TagMessage);
|
||||||
|
|
||||||
core.startGroup('Push the commit or tag');
|
|
||||||
await push(inps.PublishBranch, inps.ForceOrphan);
|
|
||||||
await pushTag(inps.TagName, inps.TagMessage);
|
|
||||||
core.endGroup();
|
|
||||||
|
|
||||||
core.info('[INFO] Action successfully completed');
|
core.info('[INFO] Action successfully completed');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (error) {
|
} catch (e) {
|
||||||
if (error instanceof Error) {
|
throw new Error(e.message);
|
||||||
throw new Error(error.message);
|
|
||||||
} else {
|
|
||||||
throw new Error('unexpected error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,15 @@ import * as github from '@actions/github';
|
|||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
const cpSpawnSync = require('child_process').spawnSync;
|
const cpSpawnSync = require('child_process').spawnSync;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
const cpexec = require('child_process').execFileSync;
|
const cpexec = require('child_process').execFileSync;
|
||||||
import {Inputs} from './interfaces';
|
import {Inputs} from './interfaces';
|
||||||
import {getHomeDir} from './utils';
|
import {getHomeDir} from './utils';
|
||||||
import {getServerUrl} from './git-utils';
|
|
||||||
|
|
||||||
export async function setSSHKey(inps: Inputs, publishRepo: string): Promise<string> {
|
export async function setSSHKey(
|
||||||
|
inps: Inputs,
|
||||||
|
publishRepo: string
|
||||||
|
): Promise<string> {
|
||||||
core.info('[INFO] setup SSH deploy key');
|
core.info('[INFO] setup SSH deploy key');
|
||||||
|
|
||||||
const homeDir = await getHomeDir();
|
const homeDir = await getHomeDir();
|
||||||
@ -21,12 +21,10 @@ export async function setSSHKey(inps: Inputs, publishRepo: string): Promise<stri
|
|||||||
await exec.exec('chmod', ['700', sshDir]);
|
await exec.exec('chmod', ['700', sshDir]);
|
||||||
|
|
||||||
const knownHosts = path.join(sshDir, 'known_hosts');
|
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 = `\
|
const cmdSSHkeyscanOutput = `\
|
||||||
# ${getServerUrl().host}.com:22 SSH-2.0-babeld-1f0633a6
|
# github.com:22 SSH-2.0-babeld-1f0633a6
|
||||||
${
|
github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
|
||||||
getServerUrl().host
|
|
||||||
} ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=
|
|
||||||
`;
|
`;
|
||||||
fs.writeFileSync(knownHosts, cmdSSHkeyscanOutput + '\n');
|
fs.writeFileSync(knownHosts, cmdSSHkeyscanOutput + '\n');
|
||||||
core.info(`[INFO] wrote ${knownHosts}`);
|
core.info(`[INFO] wrote ${knownHosts}`);
|
||||||
@ -39,8 +37,8 @@ ${
|
|||||||
|
|
||||||
const sshConfigPath = path.join(sshDir, 'config');
|
const sshConfigPath = path.join(sshDir, 'config');
|
||||||
const sshConfigContent = `\
|
const sshConfigContent = `\
|
||||||
Host ${getServerUrl().host}
|
Host github
|
||||||
HostName ${getServerUrl().host}
|
HostName github.com
|
||||||
IdentityFile ~/.ssh/github
|
IdentityFile ~/.ssh/github
|
||||||
User git
|
User git
|
||||||
`;
|
`;
|
||||||
@ -49,11 +47,6 @@ Host ${getServerUrl().host}
|
|||||||
await exec.exec('chmod', ['600', sshConfigPath]);
|
await exec.exec('chmod', ['600', sshConfigPath]);
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
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('Start-Process', ['powershell.exe', '-Verb', 'runas']);
|
||||||
await cpSpawnSync('sh', ['-c', '\'eval "$(ssh-agent)"\''], {shell: true});
|
await cpSpawnSync('sh', ['-c', '\'eval "$(ssh-agent)"\''], {shell: true});
|
||||||
await exec.exec('sc', ['config', 'ssh-agent', 'start=auto']);
|
await exec.exec('sc', ['config', 'ssh-agent', 'start=auto']);
|
||||||
@ -63,7 +56,7 @@ Watch https://github.com/peaceiris/actions-gh-pages/issues/87
|
|||||||
core.exportVariable('SSH_AUTH_SOCK', '/tmp/ssh-auth.sock');
|
core.exportVariable('SSH_AUTH_SOCK', '/tmp/ssh-auth.sock');
|
||||||
await exec.exec('ssh-add', [idRSA]);
|
await exec.exec('ssh-add', [idRSA]);
|
||||||
|
|
||||||
return `git@${getServerUrl().host}:${publishRepo}.git`;
|
return `git@github.com:${publishRepo}.git`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setGithubToken(
|
export function setGithubToken(
|
||||||
@ -80,32 +73,35 @@ export function setGithubToken(
|
|||||||
core.debug(`eventName: ${eventName}`);
|
core.debug(`eventName: ${eventName}`);
|
||||||
let isProhibitedBranch = false;
|
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') {
|
if (eventName === 'push') {
|
||||||
isProhibitedBranch = ref.match(new RegExp(`^refs/heads/${publishBranch}$`)) !== null;
|
isProhibitedBranch = ref.includes(`refs/heads/${publishBranch}`);
|
||||||
if (isProhibitedBranch) {
|
if (isProhibitedBranch) {
|
||||||
throw new Error(`\
|
throw new Error(`You deploy from ${publishBranch} to ${publishBranch}`);
|
||||||
You deploy from ${publishBranch} to ${publishBranch}
|
|
||||||
This operation is prohibited to protect your contents
|
|
||||||
`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return `https://x-access-token:${githubToken}@${getServerUrl().host}/${publishRepo}.git`;
|
if (externalRepository) {
|
||||||
|
throw new Error(
|
||||||
|
'GITHUB_TOKEN does not support to push to an external repository'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return `https://x-access-token:${githubToken}@github.com/${publishRepo}.git`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setPersonalToken(personalToken: string, publishRepo: string): string {
|
export function setPersonalToken(
|
||||||
|
personalToken: string,
|
||||||
|
publishRepo: string
|
||||||
|
): string {
|
||||||
core.info('[INFO] setup personal access token');
|
core.info('[INFO] setup personal access token');
|
||||||
return `https://x-access-token:${personalToken}@${getServerUrl().host}/${publishRepo}.git`;
|
return `https://x-access-token:${personalToken}@github.com/${publishRepo}.git`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPublishRepo(externalRepository: string, owner: string, repo: string): string {
|
export function getPublishRepo(
|
||||||
|
externalRepository: string,
|
||||||
|
owner: string,
|
||||||
|
repo: string
|
||||||
|
): string {
|
||||||
if (externalRepository) {
|
if (externalRepository) {
|
||||||
return externalRepository;
|
return externalRepository;
|
||||||
}
|
}
|
||||||
@ -138,11 +134,7 @@ export async function setTokens(inps: Inputs): Promise<string> {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error('not found deploy key or tokens');
|
throw new Error('not found deploy key or tokens');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (e) {
|
||||||
if (error instanceof Error) {
|
throw new Error(e.message);
|
||||||
throw new Error(error.message);
|
|
||||||
} else {
|
|
||||||
throw new Error('unexpected error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
46
src/utils.ts
@ -23,48 +23,42 @@ export async function getWorkDirName(unixTime: string): Promise<string> {
|
|||||||
return workDirName;
|
return workDirName;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createDir(dirPath: string): Promise<void> {
|
export async function createWorkDir(workDirName: string): Promise<void> {
|
||||||
await io.mkdirP(dirPath);
|
await io.mkdirP(workDirName);
|
||||||
core.debug(`Created directory ${dirPath}`);
|
core.debug(`Created: ${workDirName}`);
|
||||||
return;
|
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) {
|
if (DisableNoJekyll) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const filepath = path.join(workDir, '.nojekyll');
|
if (PublishBranch === 'master' || PublishBranch === 'gh-pages') {
|
||||||
if (fs.existsSync(filepath)) {
|
const filepath = path.join(workDir, '.nojekyll');
|
||||||
return;
|
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 === '') {
|
if (content === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const filepath = path.join(workDir, 'CNAME');
|
const filepath = path.join(workDir, 'CNAME');
|
||||||
if (fs.existsSync(filepath)) {
|
if (fs.existsSync(filepath)) {
|
||||||
core.info(`CNAME already exists, skip adding CNAME`);
|
core.warning(`CNAME already exists, skip adding CNAME`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fs.writeFileSync(filepath, content + '\n');
|
fs.writeFileSync(filepath, content + '\n');
|
||||||
core.info(`[INFO] Created ${filepath}`);
|
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;
|
|
||||||
}
|
|
||||||
|
@ -1,15 +1,64 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["ES2019"],
|
/* Basic Options */
|
||||||
"module": "commonjs",
|
// "incremental": true, /* Enable incremental compilation */
|
||||||
"target": "ES2019",
|
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||||
"sourceMap": true,
|
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||||
"outDir": "./lib",
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
"rootDir": "./src",
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
"removeComments": true,
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||||
"strict": true,
|
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||||
"noImplicitAny": true,
|
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||||
"esModuleInterop": true,
|
"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
|
"resolveJsonModule": true
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "**/*.test.ts"]
|
"exclude": ["node_modules", "**/*.test.ts"]
|
||||||
|