Update docs #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update docs | |
on: | |
workflow_dispatch: | |
jobs: | |
fetch_readmes: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
# We must fetch at least the immediate parents so that if this is | |
# a pull request then we can checkout the head. | |
fetch-depth: 2 | |
- name: Git configuration | |
uses: michijs/.github/.github/actions/set-git-config-github-actions@main | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 14 | |
- name: Fetch npm Versions | |
id: fetch_versions | |
run: | | |
VERSIONS=$(npm show @michijs/michijs versions --json) | |
FILTERED_VERSIONS=$(echo "$VERSIONS" | jq 'map(select(. | test("beta|rc") | not))') | |
echo "::set-output name=versions::$FILTERED_VERSIONS" | |
- name: Retrieve READMEs | |
id: fetch_readmes | |
run: | | |
VERSIONS="${{ steps.fetch_versions.outputs.versions }}" | |
for version in $(echo "${VERSIONS}" | jq -r '.[]'); do | |
if [[ $version == $(echo "${VERSIONS}" | jq -r '.[-1]') ]]; then | |
wget -O README.md https://raw.githubusercontent.com/michijs/michijs/v$version/README.md | |
else | |
wget -O v$version.md https://raw.githubusercontent.com/michijs/michijs/v$version/README.md | |
fi | |
done | |
- name: Commit changes | |
uses: michijs/.github/.github/actions/commit-if-changes@main | |
with: | |
message: "Readme update" | |
- name: Push changes | |
uses: michijs/.github/.github/actions/pull-and-push@main | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} |