mirror of
https://github.com/axios/axios.git
synced 2026-04-11 14:21:59 +08:00
refactor: ci and build (#7340)
* chore: add mise * chore: re-position ci * chore: move sponsors script * chore: fix yml * chore: yml * fix: yml * fix: yml * chore: tweak sponsor yml * chore: implement security suggestion * chore: update templates for issues and PRs and update all workflows * fix: copilot feedback * feat: always run CI * fix: linked resources * chore: cancel run if new run starts * feat: generate release notes with copilot
This commit is contained in:
parent
ab06109b40
commit
8ff6c19e2d
15
.github/ISSUE_TEMPLATE.md
vendored
15
.github/ISSUE_TEMPLATE.md
vendored
@ -2,12 +2,12 @@
|
||||
|
||||
Please read and follow the instructions before submitting an issue:
|
||||
|
||||
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
|
||||
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/main/README.md). It may contain information that helps you solve your issue.
|
||||
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
|
||||
- Please, ensure your issue is not related to CORS or Mixed Content Issue (only relevant for browsers)
|
||||
- If you aren't sure that the issue is caused by axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
|
||||
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
|
||||
- If you need a new feature there's a chance it's already implemented in a [library](https://github.com/axios/axios/blob/master/ECOSYSTEM.md) or you can implement it using [interceptors](https://github.com/axios/axios#interceptors).
|
||||
- If you need a new feature there's a chance it's already implemented in a [library](https://github.com/axios/axios/blob/main/ECOSYSTEM.md) or you can implement it using [interceptors](https://github.com/axios/axios#interceptors).
|
||||
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.
|
||||
|
||||
**⚠️👆 Delete the instructions before submitting the issue 👆⚠️**
|
||||
@ -23,8 +23,9 @@ If you're reporting a bug, include the relevant code and stack traces to debug i
|
||||
If you're requesting a feature, include some context and examples of code using it.
|
||||
|
||||
#### Environment
|
||||
- **Axios Version [e.g. 1.7.0]**
|
||||
- **Target platform [e.g Node / Browser / React Native version where Axios is running]**
|
||||
- **Adapter [e.g. FETCH / XHR / HTTP]**
|
||||
- Additional Library/Framework Versions [e.g. React 16.7]
|
||||
- OS: [e.g. iOS 12.1.0, OSX 10.13.4]
|
||||
|
||||
- **Axios Version [e.g. 1.7.0]**
|
||||
- **Target platform [e.g Node / Browser / React Native version where Axios is running]**
|
||||
- **Adapter [e.g. FETCH / XHR / HTTP]**
|
||||
- Additional Library/Framework Versions [e.g. React 16.7]
|
||||
- OS: [e.g. iOS 12.1.0, OSX 10.13.4]
|
||||
|
||||
102
.github/ISSUE_TEMPLATE/BUG_REPORT.yml
vendored
102
.github/ISSUE_TEMPLATE/BUG_REPORT.yml
vendored
@ -1,102 +0,0 @@
|
||||
name: '🐛 Bug Report'
|
||||
description: Report a reproducible bug.
|
||||
labels: ['possible bug']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: 'Please read and follow the instructions before submitting an issue:'
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
|
||||
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
|
||||
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
|
||||
- Ensure it isn't already fixed in the latest Axios version.
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: '⚠️👆 Feel free to these instructions before submitting the issue 👆⚠️'
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 'Describe the bug'
|
||||
description: A clear and concise description of what the bug is.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduce
|
||||
attributes:
|
||||
label: 'To Reproduce'
|
||||
description: |
|
||||
Code snippet to reproduce, ideally if you can provide a live example in https://codesandbox.io/ sandbox or a repository that illustrates the issue.
|
||||
(You can use https://codesandbox.io/p/sandbox/zen-knuth-9hvhzq as a node sandbox template, or https://codesandbox.io/s/axios-browser-issue-2l8jec as a browser template)
|
||||
**If your problem is not reproducible, please file under Support or Usage Question**
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: code-snippet
|
||||
attributes:
|
||||
label: 'Code snippet'
|
||||
render: js
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: 'Expected behavior'
|
||||
description: A clear and concise description of what you expected to happen.
|
||||
validations:
|
||||
required: false
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: Environment
|
||||
- type: input
|
||||
id: axios-version
|
||||
attributes:
|
||||
label: 'Axios Version'
|
||||
placeholder: 'e.g. 0.18.0'
|
||||
- type: input
|
||||
id: adapter-version
|
||||
attributes:
|
||||
label: 'Adapter Version'
|
||||
placeholder: 'e.g. XHR/HTTP'
|
||||
- type: input
|
||||
id: browser
|
||||
attributes:
|
||||
label: 'Browser'
|
||||
placeholder: 'e.g. Chrome, Safari'
|
||||
- type: input
|
||||
id: browser-version
|
||||
attributes:
|
||||
label: 'Browser Version'
|
||||
placeholder: 'e.g. 42'
|
||||
- type: input
|
||||
id: node-version
|
||||
attributes:
|
||||
label: 'Node.js Version'
|
||||
description: 'node --version'
|
||||
placeholder: 'e.g. 13.0.1'
|
||||
- type: input
|
||||
id: os
|
||||
attributes:
|
||||
label: 'OS'
|
||||
placeholder: 'e.g. iOS 16.0.2, OSX 12.6.0'
|
||||
- type: textarea
|
||||
id: other-version
|
||||
attributes:
|
||||
label: 'Additional Library Versions'
|
||||
placeholder: |
|
||||
e.g.
|
||||
React 16.7,
|
||||
React Native 0.58.0
|
||||
render: bash
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: additional-context
|
||||
attributes:
|
||||
label: 'Additional context/Screenshots'
|
||||
description: Add any other context about the problem here. If applicable, add screenshots to help explain.
|
||||
render: bash
|
||||
validations:
|
||||
required: false
|
||||
|
||||
30
.github/ISSUE_TEMPLATE/DOCUMENTATION.yml
vendored
30
.github/ISSUE_TEMPLATE/DOCUMENTATION.yml
vendored
@ -1,30 +0,0 @@
|
||||
name: '📝 Documentation'
|
||||
description: Report an error or area that needs clarification.
|
||||
labels: ['documentation']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: 'If you found an area that needs clarification, feel free to open a PR or list the section/content that could be improved below'
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: '⚠️👆 Feel free to these instructions before submitting the issue 👆⚠️'
|
||||
- type: textarea
|
||||
id: content
|
||||
attributes:
|
||||
label: 'Section/Content To Improve'
|
||||
description: Quote or link to section
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: 'Suggested Improvement'
|
||||
description: Identify what is confusing or incorrect and what could make it better
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: files
|
||||
attributes:
|
||||
label: 'Relevant File(s)'
|
||||
placeholder: e.g. README.md
|
||||
render: bash
|
||||
46
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml
vendored
46
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml
vendored
@ -1,46 +0,0 @@
|
||||
name: '✨ Feature Request'
|
||||
description: Suggest an idea or feature.
|
||||
labels: ['feature']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: 'Please read and follow the instructions before submitting an issue:'
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
|
||||
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
|
||||
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: '⚠️👆 Feel free to these instructions before submitting the issue 👆⚠️'
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 'Is your feature request related to a problem? Please describe.'
|
||||
description: A clear and concise description of what the problem is.
|
||||
placeholder: I'm always frustrated when [...]
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: Describe the solution you'd like
|
||||
description: A clear and concise description of what you want to happen.
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: alternative
|
||||
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
|
||||
id: additional-context
|
||||
attributes:
|
||||
label: 'Additional context/Screenshots'
|
||||
description: Add any other context or screenshots about the feature request here.
|
||||
render: bash
|
||||
validations:
|
||||
required: false
|
||||
92
.github/ISSUE_TEMPLATE/SUPPORT_QUESTION.yml
vendored
92
.github/ISSUE_TEMPLATE/SUPPORT_QUESTION.yml
vendored
@ -1,92 +0,0 @@
|
||||
name: '🤔 Support or Usage Question'
|
||||
description: Get help using Axios.
|
||||
labels: ['question']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: 'Please read and follow the instructions before submitting an issue:'
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
|
||||
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
|
||||
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
|
||||
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: '⚠️👆 Feel free to delete these instructions before submitting the issue 👆⚠️'
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 'Describe the issue'
|
||||
description: A clear and concise description of what the issue is.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: example
|
||||
attributes:
|
||||
label: 'Example Code'
|
||||
description: Code snippet to illustrate your question
|
||||
render: js
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: 'Expected behavior'
|
||||
description: A clear and concise description of what you expected to happen.
|
||||
validations:
|
||||
required: false
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: Environment
|
||||
- type: input
|
||||
id: axios-version
|
||||
attributes:
|
||||
label: 'Axios Version'
|
||||
placeholder: 'e.g. 0.18.0'
|
||||
- type: input
|
||||
id: adapter-version
|
||||
attributes:
|
||||
label: 'Adapter Version'
|
||||
placeholder: 'e.g. XHR/HTTP'
|
||||
- type: input
|
||||
id: browser
|
||||
attributes:
|
||||
label: 'Browser'
|
||||
placeholder: 'e.g. Chrome, Safari'
|
||||
- type: input
|
||||
id: browser-version
|
||||
attributes:
|
||||
label: 'Browser Version'
|
||||
placeholder: 'e.g. 42'
|
||||
- type: input
|
||||
id: node-version
|
||||
attributes:
|
||||
label: 'Node.js Version'
|
||||
description: 'node --version'
|
||||
placeholder: 'e.g. 13.0.1'
|
||||
- type: input
|
||||
id: os
|
||||
attributes:
|
||||
label: 'OS'
|
||||
placeholder: 'e.g. iOS 16.0.2, OSX 12.6.0'
|
||||
- type: textarea
|
||||
id: other-version
|
||||
attributes:
|
||||
label: 'Additional Library Versions'
|
||||
placeholder: |
|
||||
e.g.
|
||||
React 16.7,
|
||||
React Native 0.58.0
|
||||
render: bash
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: additional-context
|
||||
attributes:
|
||||
label: 'Additional context/Screenshots'
|
||||
description: Add any other context about the problem here. If applicable, add screenshots to help explain.
|
||||
render: bash
|
||||
validations:
|
||||
required: false
|
||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
1
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -1 +0,0 @@
|
||||
blank_issues_enabled: true
|
||||
9
.github/PULL_REQUEST_TEMPLATE.md
vendored
9
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,13 +1,14 @@
|
||||
<!-- Click "Preview" for a more readable version -->
|
||||
<!-- Instructions
|
||||
|
||||
#### Instructions
|
||||
If you would like to add a PR description you may do so or let our AI agent create one, after the creation
|
||||
you may then edit the file if the AI agent got it wrong.
|
||||
|
||||
Please read and follow the instructions before creating and submitting a pull request:
|
||||
|
||||
- Create an issue explaining the feature. It could save you some effort in case we don't consider it should be included in axios.
|
||||
- If you're fixing a bug, try to commit the failing test/s and the code fixing it in different commits.
|
||||
- Ensure you're following our [contributing guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md).
|
||||
- Ensure you're following our [contributing guide](https://github.com/axios/axios/blob/main/CONTRIBUTING.md).
|
||||
|
||||
**⚠️👆 Delete the instructions before submitting the pull request 👆⚠️**
|
||||
|
||||
Describe your pull request here.
|
||||
Describe your pull request here. -->
|
||||
|
||||
34
.github/labeler.yml
vendored
34
.github/labeler.yml
vendored
@ -1,34 +0,0 @@
|
||||
|
||||
"pr::docs":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: '**.md'
|
||||
|
||||
"pr::code":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: 'lib/**.js'
|
||||
|
||||
"pr::types":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['index.d.ts', 'index.d.cts']
|
||||
|
||||
"pr::tests":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: 'test/**.js'
|
||||
|
||||
"pr::github":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: '.github/**'
|
||||
|
||||
"pr::examples":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: 'examples/**.js'
|
||||
|
||||
"pr::ci":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['bin/**', 'rollup.config.js']
|
||||
|
||||
"pr::feature":
|
||||
- head-branch: ['feature', 'feat']
|
||||
|
||||
"pr::fix":
|
||||
- head-branch: ['fix', 'bug']
|
||||
71
.github/workflows/ci.yml
vendored
71
.github/workflows/ci.yml
vendored
@ -1,71 +0,0 @@
|
||||
name: 'CI'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
- '*/*'
|
||||
- '**'
|
||||
- '!sponsors'
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
- '*/*'
|
||||
- '**'
|
||||
- '!sponsors'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x, 14.x, 16.x, 18.x, 20.x, 22.x, 24.x]
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: true
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v47
|
||||
- name: List all changed files
|
||||
run: |
|
||||
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
|
||||
echo "$file was changed"
|
||||
done
|
||||
- name: Check changes
|
||||
id: changed-ignored
|
||||
uses: tj-actions/changed-files@v47
|
||||
with:
|
||||
files: |
|
||||
**.md
|
||||
sandbox/**
|
||||
examples/**
|
||||
.github/**
|
||||
templates/**
|
||||
bin/**
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
if: steps.changed-ignored.outputs.only_modified == 'false'
|
||||
- run: npm ci
|
||||
if: steps.changed-ignored.outputs.only_modified == 'false'
|
||||
- run: npm run build
|
||||
if: steps.changed-ignored.outputs.only_modified == 'false'
|
||||
- name: Run Server tests
|
||||
run: npm run test:node
|
||||
if: steps.changed-ignored.outputs.only_modified == 'false'
|
||||
# We run browser tests only on one version of the node, since client tests do not depend on the server environment.
|
||||
- name: Run browser tests
|
||||
run: npm run test:browser
|
||||
if: steps.changed-ignored.outputs.only_modified == 'false' && matrix.node-version == '22.x'
|
||||
- name: Run package tests
|
||||
run: npm run test:package
|
||||
if: steps.changed-ignored.outputs.only_modified == 'false'
|
||||
47
.github/workflows/codeql-analysis.yml
vendored
47
.github/workflows/codeql-analysis.yml
vendored
@ -1,47 +0,0 @@
|
||||
name: 'CodeQL'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
- '*/*'
|
||||
- '**'
|
||||
- '!sponsors'
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
- '*/*'
|
||||
- '**'
|
||||
- '!sponsors'
|
||||
schedule:
|
||||
- cron: '21 23 * * 5'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'javascript' ]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v4
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
queries: security-extended,security-and-quality
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v4
|
||||
16
.github/workflows/depsreview.yaml
vendored
16
.github/workflows/depsreview.yaml
vendored
@ -1,16 +0,0 @@
|
||||
name: 'Dependency Review'
|
||||
on: [pull_request]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
dependency-review:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Checkout Repository'
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: 'Dependency Review'
|
||||
uses: actions/dependency-review-action@v4
|
||||
32
.github/workflows/labeler.yml
vendored
32
.github/workflows/labeler.yml
vendored
@ -1,32 +0,0 @@
|
||||
name: "PR Labeler"
|
||||
on:
|
||||
pull_request_target:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
prs:
|
||||
required: false
|
||||
description: "pr number"
|
||||
|
||||
jobs:
|
||||
labeler:
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: git config
|
||||
run: |
|
||||
git config user.name "${GITHUB_ACTOR}"
|
||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||
- name: Set PR number
|
||||
id: set-pr
|
||||
run: |
|
||||
echo "Using PR number: ${{ github.event.inputs.prs || github.event.pull_request.number }}"
|
||||
echo "pr=${{ github.event.inputs.prs || github.event.pull_request.number }}" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: actions/labeler@v6
|
||||
with:
|
||||
pr-number: ${{ steps.set-pr.outputs.pr }}
|
||||
51
.github/workflows/notify.yml
vendored
51
.github/workflows/notify.yml
vendored
@ -1,51 +0,0 @@
|
||||
name: notify
|
||||
|
||||
on:
|
||||
#workflow_run:
|
||||
# workflows: ["publish"]
|
||||
# types:
|
||||
# - completed
|
||||
#repository_dispatch:
|
||||
# types: [ notify ]
|
||||
#release:
|
||||
# types: [published]
|
||||
# branches:
|
||||
# - main
|
||||
# - 'v**'
|
||||
#push:
|
||||
# tags:
|
||||
# - 'v[0-9]+.[0-9]+.[0-9]+'
|
||||
# branches:
|
||||
# - main
|
||||
# - 'v**'
|
||||
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
required: false
|
||||
jobs:
|
||||
notify:
|
||||
runs-on: ubuntu-latest
|
||||
#if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
|
||||
steps:
|
||||
#- name: Dump GitHub context
|
||||
# env:
|
||||
# GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||
# run: echo "$GITHUB_CONTEXT"
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: git config
|
||||
run: |
|
||||
git config user.name "${GITHUB_ACTOR}"
|
||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 18
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
- name: Notify published PRs
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: node ./bin/actions/notify_published.js --tag ${{ github.event.inputs.tag || github.event.release.tag_name }}
|
||||
30
.github/workflows/npm-tag.yml
vendored
30
.github/workflows/npm-tag.yml
vendored
@ -1,30 +0,0 @@
|
||||
name: NPM Tag
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
tag:
|
||||
required: true
|
||||
default: "latest"
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: git config
|
||||
run: |
|
||||
git config user.name "${GITHUB_ACTOR}"
|
||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 18
|
||||
registry-url: https://registry.npmjs.org/
|
||||
############# TAG RELEASE ##############
|
||||
- name: Tag release
|
||||
run: npm dist-tag add axios@${{ github.event.inputs.version }} ${{ github.event.inputs.tag }}
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
||||
85
.github/workflows/pr.yml
vendored
85
.github/workflows/pr.yml
vendored
@ -1,85 +0,0 @@
|
||||
name: Release PR
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
type:
|
||||
type: choice
|
||||
description: Choose release type
|
||||
options:
|
||||
- auto
|
||||
- patch
|
||||
- minor
|
||||
- major
|
||||
default: auto
|
||||
beta:
|
||||
type: boolean
|
||||
description: Prerelease
|
||||
default: false
|
||||
jobs:
|
||||
releaseIt:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: git config
|
||||
run: |
|
||||
git config user.name "${GITHUB_ACTOR}"
|
||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 16
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
- name: Prepare release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
TYPE_ARG: ${{ fromJSON('{"auto":"", "patch":"patch", "minor":"minor", "major":"major"}')[github.event.inputs.type] }}
|
||||
BETA_ARG: ${{ github.event.inputs.beta == 'true' && '--preRelease=beta' || '' }}
|
||||
run: npm run release -- $TYPE_ARG --ci --verbose --no-git.push --no-git.commit --no-git.tag --no-github $BETA_ARG $DRY_ARG
|
||||
- name: Show git status
|
||||
if: failure()
|
||||
run: git status && git diff
|
||||
- name: Add contributors list to CHANGELOG.md
|
||||
run: npm run release:changelog:fix
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: get-npm-version
|
||||
id: package-version
|
||||
uses: martinbeentjes/npm-get-version-action@main
|
||||
- name: Extract release notes
|
||||
id: extract-release-notes
|
||||
uses: ffurrer2/extract-release-notes@v3
|
||||
- name: Generate PR body
|
||||
id: body
|
||||
uses: mathiasvr/command-output@v1
|
||||
with:
|
||||
run: node ./bin/pr.js
|
||||
- name: Create pull request
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
id: cpr
|
||||
with:
|
||||
branch: release
|
||||
delete-branch: true
|
||||
commit-message: 'chore(release): v${{ steps.package-version.outputs.current-version}}'
|
||||
title: '[Release] v${{ steps.package-version.outputs.current-version}}'
|
||||
body: |
|
||||
${{ steps.body.outputs.stdout }}
|
||||
## Release notes:
|
||||
${{ steps.extract-release-notes.outputs.release_notes }}
|
||||
labels: |
|
||||
release
|
||||
bot
|
||||
signoff: false
|
||||
#team-reviewers: |
|
||||
# owners
|
||||
# maintainers
|
||||
#assignees: jasonsaayman
|
||||
#reviewers: jasonsaayman
|
||||
draft: false
|
||||
- name: Show PR link
|
||||
if: ${{ steps.cpr.outputs.pull-request-url }}
|
||||
run: |
|
||||
echo "Axios Release v${{ steps.package-version.outputs.current-version}}' pull request - ${{ steps.cpr.outputs.pull-request-url }}"
|
||||
106
.github/workflows/publish.yml
vendored
106
.github/workflows/publish.yml
vendored
@ -1,85 +1,41 @@
|
||||
name: Publish
|
||||
name: Publish package to NPM
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
branches:
|
||||
- main
|
||||
- 'v**'
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && github.event.pull_request.head.label == 'axios:release')
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: "Release PR info"
|
||||
if: github.event_name != 'workflow_dispatch'
|
||||
run: echo "PR ${{ github.event.number }}"
|
||||
- uses: actions/checkout@v6
|
||||
- name: git config
|
||||
run: |
|
||||
git config user.name "${GITHUB_ACTOR}"
|
||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 18
|
||||
registry-url: https://registry.npmjs.org/
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
- name: get-npm-version
|
||||
id: package-version
|
||||
uses: martinbeentjes/npm-get-version-action@main
|
||||
- name: Extract release notes
|
||||
id: extract-release-notes
|
||||
uses: ffurrer2/extract-release-notes@v3
|
||||
- name: Check versions
|
||||
run: node ./bin/check-build-version.js
|
||||
############# TAG RELEASE ##############
|
||||
- name: "Push tag v${{ steps.package-version.outputs.current-version }}"
|
||||
uses: rickstaa/action-create-tag@v1
|
||||
id: tag_version
|
||||
with:
|
||||
tag: "v${{ steps.package-version.outputs.current-version }}"
|
||||
############# RESOLVE NPM TAG ##############
|
||||
- name: NPM TAG
|
||||
id: 'npm_tag'
|
||||
run: node ./bin/resolveNPMTag.js
|
||||
############# GITHUB RELEASE ##############
|
||||
- name: "Create a GitHub release v${{ steps.package-version.outputs.current-version }}"
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
tag: "v${{ steps.package-version.outputs.current-version }}"
|
||||
name: "Release v${{ steps.package-version.outputs.current-version }}"
|
||||
body: |
|
||||
## Release notes:
|
||||
${{ steps.extract-release-notes.outputs.release_notes }}
|
||||
############# NPM RELEASE ##############
|
||||
- name: Publish the release to NPM
|
||||
run: npm publish --provenance --access public --tag ${{ steps.npm_tag.outputs.tag || 'latest' }}
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
||||
notify:
|
||||
needs: [publish]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: git config
|
||||
run: |
|
||||
git config user.name "${GITHUB_ACTOR}"
|
||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||
- name: Setup node
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v6
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 18
|
||||
node-version: 24.x
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
############# Add release comments and tags to published PRs ##############
|
||||
- name: Notify published PRs
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Build project
|
||||
run: npm run build
|
||||
- name: Publish to NPM
|
||||
run: npm publish --provenance --access public
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
- name: Create release tag on GitHub
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: node ./bin/actions/notify_published.js --tag ${{ github.event.inputs.tag || github.event.release.tag_name }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
run: |
|
||||
gh release create "$TAG" \
|
||||
--repo="$GITHUB_REPOSITORY" \
|
||||
--title="${GITHUB_REPOSITORY#*/} ${TAG#v}" \
|
||||
--generate-notes
|
||||
|
||||
72
.github/workflows/release-branch.yml
vendored
Normal file
72
.github/workflows/release-branch.yml
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
name: Create release branch
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
type:
|
||||
type: choice
|
||||
description: Choose release type
|
||||
options:
|
||||
- auto
|
||||
- patch
|
||||
- minor
|
||||
- major
|
||||
default: auto
|
||||
beta:
|
||||
type: boolean
|
||||
description: Prerelease
|
||||
default: false
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v6
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 24.x
|
||||
cache: npm
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Bump version
|
||||
id: bump_version
|
||||
uses: phips28/gh-action-bump-version@v9
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
version-type: ${{ github.event.inputs.type }}
|
||||
default: ${{ github.event.inputs.beta == true && 'prerelease' || 'patch' }}
|
||||
commit-message: "chore(release): prepare release ${{version}}"
|
||||
tag-prefix: "v"
|
||||
skip-tag: true
|
||||
skip-push: true
|
||||
- name: Build project
|
||||
run: npm run build
|
||||
- name: Run unit tests
|
||||
run: npm run test:node
|
||||
- name: Run package tests
|
||||
run: npm run test:package
|
||||
- name: Run browser tests
|
||||
run: npm run test:browser
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: "chore(release): prepare release ${{ steps.bump_version.outputs.newTag }}"
|
||||
branch: "release/${{ steps.bump_version.outputs.newTag }}"
|
||||
title: "chore(release): prepare release ${{ steps.bump_version.outputs.newTag }}"
|
||||
body: "This PR prepares the release ${{ steps.bump_version.outputs.newTag }}."
|
||||
base: main
|
||||
maintainer-can-modify: true
|
||||
draft: false
|
||||
labels: |
|
||||
type::automated-pr
|
||||
priority::high
|
||||
commit::chore
|
||||
61
.github/workflows/run-ci.yml
vendored
Normal file
61
.github/workflows/run-ci.yml
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
name: Continuous integration
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- "*"
|
||||
- "*/*"
|
||||
- "**"
|
||||
- "!sponsors"
|
||||
- "!release/**"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x, 14.x, 16.x, 18.x, 20.x, 22.x, 24.x]
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: true
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Build project
|
||||
run: npm run build
|
||||
- name: Run unit tests
|
||||
run: npm run test:node
|
||||
- name: Run package tests
|
||||
run: npm run test:package
|
||||
- name: Run browser tests
|
||||
run: npm run test:browser
|
||||
if: matrix.node-version == '24.x'
|
||||
- name: Dependency Review
|
||||
uses: actions/dependency-review-action@v4
|
||||
if: matrix.node-version == '24.x'
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v4
|
||||
with:
|
||||
languages: javascript
|
||||
queries: security-extended,security-and-quality
|
||||
if: matrix.node-version == '24.x'
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v4
|
||||
if: matrix.node-version == '24.x'
|
||||
72
.github/workflows/sponsors.yml
vendored
72
.github/workflows/sponsors.yml
vendored
@ -1,72 +0,0 @@
|
||||
name: Update Readme sponsor list
|
||||
on:
|
||||
workflow_dispatch:
|
||||
repository_dispatch:
|
||||
types:
|
||||
- webhook
|
||||
schedule:
|
||||
# Run at 0000 daily
|
||||
- cron: '0 1 * * *'
|
||||
jobs:
|
||||
sponsors:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: git config
|
||||
run: |
|
||||
git config user.name "${GITHUB_ACTOR}"
|
||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 16
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
- name: Check sponsors updates
|
||||
id: sponsors
|
||||
run: node ./bin/sponsors.js
|
||||
- name: Notify status
|
||||
if: ${{ steps.sponsors.outputs.changed == 'true'}}
|
||||
run: |
|
||||
echo "Sponsor block has changed. Creating PR with updates..."
|
||||
- name: Read sponsors.md file content
|
||||
if: ${{ steps.sponsors.outputs.changed == 'true'}}
|
||||
id: read_file
|
||||
run: |
|
||||
echo 'CONTENT<<EOF' >> $GITHUB_ENV
|
||||
cat ./temp/sponsors.md >> $GITHUB_ENV
|
||||
echo 'EOF' >> $GITHUB_ENV
|
||||
shell: bash
|
||||
- name: Echo
|
||||
run: |
|
||||
echo "$CONTENT"
|
||||
- name: Create pull request
|
||||
if: ${{ steps.sponsors.outputs.changed == 'true'}}
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
id: cpr
|
||||
with:
|
||||
branch: sponsors
|
||||
delete-branch: true
|
||||
commit-message: 'chore(sponsor): update sponsor block'
|
||||
title: '[Chore] Update sponsor block'
|
||||
body: |
|
||||
**New sponsor block update:**
|
||||
${{ env.CONTENT }}
|
||||
labels: |
|
||||
pr::docs
|
||||
bot
|
||||
automerge
|
||||
signoff: false
|
||||
#team-reviewers: |
|
||||
# owners
|
||||
# maintainers
|
||||
#assignees: jasonsaayman
|
||||
#reviewers: jasonsaayman
|
||||
draft: false
|
||||
- name: Show PR link
|
||||
if: ${{ steps.sponsors.outputs.changed == 'true'}}
|
||||
run: |
|
||||
echo "Sponsor block has changed. Creating PR..."
|
||||
echo "Axios Release v${{ steps.package-version.outputs.current-version}}' pull request - ${{ steps.cpr.outputs.pull-request-url }}"
|
||||
34
.github/workflows/stale.yml
vendored
34
.github/workflows/stale.yml
vendored
@ -1,34 +0,0 @@
|
||||
name: 'Close Stale'
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * 1'
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
permissions:
|
||||
issues: write # for actions/stale to close stale issues
|
||||
pull-requests: write # for actions/stale to close stale PRs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Close Stale Issues
|
||||
uses: actions/stale@v10
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-message: |
|
||||
Hello! :wave:
|
||||
|
||||
This issue is being automatically marked as stale because it has not been updated in a while. Please confirm that the issue is still present and reproducible. If no updates or new comments are received the issue will be closed in a few days.
|
||||
|
||||
Thanks.
|
||||
stale-pr-message: |
|
||||
Hello! :wave:
|
||||
|
||||
This pull request is being automatically marked as stale because it has not been updated in a while. Please confirm that the issue is still present and reproducible. If no updates or new comments are received the pull request will be closed in a few days.
|
||||
|
||||
Thanks.
|
||||
stale-issue-label: 'status:stale'
|
||||
stale-pr-label: 'status:stale'
|
||||
only-labels: 'status:more info needed'
|
||||
days-before-stale: 30
|
||||
days-before-close: 14
|
||||
64
.github/workflows/update-sponsor-block.yml
vendored
Normal file
64
.github/workflows/update-sponsor-block.yml
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
name: Update readme sponsor block
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
repository_dispatch:
|
||||
types:
|
||||
- webhook
|
||||
schedule:
|
||||
- cron: "0 1 * * *"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
sponsors:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: git config
|
||||
run: |
|
||||
git config user.name "${GITHUB_ACTOR}"
|
||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 24.x
|
||||
cache: npm
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Check if sponsors require updates
|
||||
id: sponsors-requires-update
|
||||
run: node ../../bin/update-sponsors.js
|
||||
- name: Read sponsors.md file content
|
||||
run: |
|
||||
echo 'CONTENT<<EOF' >> $GITHUB_ENV
|
||||
cat ./temp/sponsors.md >> $GITHUB_ENV
|
||||
echo 'EOF' >> $GITHUB_ENV
|
||||
shell: bash
|
||||
if: steps.sponsors-requires-update.outputs.changed == 'true'
|
||||
- name: Echo sponsors content
|
||||
run: |
|
||||
echo "$CONTENT"
|
||||
if: steps.sponsors-requires-update.outputs.changed == 'true'
|
||||
- name: Create pull request
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
branch: sponsors
|
||||
delete-branch: true
|
||||
commit-message: "chore(sponsor): update sponsor block"
|
||||
title: "[Chore] Update sponsor block"
|
||||
body: |
|
||||
**New sponsor block update:**
|
||||
${{ env.CONTENT }}
|
||||
labels: |
|
||||
commit::docs
|
||||
priority::high
|
||||
type::automated-pr
|
||||
signoff: false
|
||||
draft: false
|
||||
if: steps.sponsors-requires-update.outputs.changed == 'true'
|
||||
@ -1,41 +1,48 @@
|
||||
import fs from "fs/promises";
|
||||
import _axios from '../index.js';
|
||||
import {exec} from "./repo.js";
|
||||
import {colorize} from "./helpers/colorize.js";
|
||||
import _axios from "../index.js";
|
||||
import { exec } from "./repo.js";
|
||||
import { colorize } from "./helpers/colorize.js";
|
||||
|
||||
const axios = _axios.create({
|
||||
headers: {
|
||||
"User-Agent": 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
|
||||
}
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
|
||||
},
|
||||
});
|
||||
|
||||
const getWithRetry = (url, retries = 3) => {
|
||||
let counter = 0;
|
||||
const doRequest = async () => {
|
||||
try {
|
||||
return await axios.get(url)
|
||||
return await axios.get(url);
|
||||
} catch (err) {
|
||||
if (counter++ >= retries) {
|
||||
throw err;
|
||||
}
|
||||
await new Promise(resolve => setTimeout(resolve, counter ** counter * 1000));
|
||||
await new Promise((resolve) =>
|
||||
setTimeout(resolve, counter ** counter * 1000),
|
||||
);
|
||||
return doRequest();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return doRequest();
|
||||
};
|
||||
|
||||
const updateReadmeSponsors = async (url, path, marker = '<!--<div>marker</div>-->') => {
|
||||
const updateReadmeSponsors = async (
|
||||
url,
|
||||
path,
|
||||
marker = "<!--<div>marker</div>-->",
|
||||
) => {
|
||||
let fileContent = (await fs.readFile(path)).toString();
|
||||
|
||||
const index = fileContent.indexOf(marker);
|
||||
|
||||
if(index >= 0) {
|
||||
if (index >= 0) {
|
||||
const readmeContent = fileContent.slice(index);
|
||||
|
||||
let {data: sponsorContent} = await getWithRetry(url);
|
||||
sponsorContent += '\n';
|
||||
let { data: sponsorContent } = await getWithRetry(url);
|
||||
sponsorContent += "\n";
|
||||
|
||||
const currentSponsorContent = fileContent.slice(0, index);
|
||||
|
||||
@ -47,18 +54,22 @@ const updateReadmeSponsors = async (url, path, marker = '<!--<div>marker</div>--
|
||||
console.log(colorize()`Sponsor block in [${path}] is up to date`);
|
||||
}
|
||||
} else {
|
||||
console.warn(colorize()`Can not find marker (${marker}) in ${path} to inject sponsor block`);
|
||||
console.warn(
|
||||
colorize()`Can not find marker (${marker}) in ${path} to inject sponsor block`,
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
(async(url) => {
|
||||
const newContent = await updateReadmeSponsors(url, './README.md');
|
||||
(async (url) => {
|
||||
const newContent = await updateReadmeSponsors(url, "./README.md");
|
||||
|
||||
await exec(`echo "changed=${newContent ? 'true' : 'false'}" >> $GITHUB_OUTPUT`);
|
||||
await exec(
|
||||
`echo "changed=${newContent ? "true" : "false"}" >> $GITHUB_OUTPUT`,
|
||||
);
|
||||
if (newContent !== false) {
|
||||
await fs.mkdir('./temp').catch(() => {});
|
||||
await fs.writeFile('./temp/sponsors.md', newContent);
|
||||
await fs.mkdir("./temp").catch(() => {});
|
||||
await fs.writeFile("./temp/sponsors.md", newContent);
|
||||
}
|
||||
})('https://axios-http.com/data/sponsors.md');
|
||||
})("https://axios-http.com/data/sponsors.md");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user