Merge pull request #1869 from jolelievre/node-20 #2326
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: Test Build | |
on: [push, pull_request] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Hugo Site | |
uses: actions/checkout@v2 | |
with: | |
repository: prestashop/devdocs-site | |
submodules: true | |
- name: Checkout PR | |
uses: actions/checkout@v2 | |
with: | |
path: _current/ | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: '0.121.1' | |
extended: true | |
- name: Find version from branch name (pull request) | |
if: ${{ github.event_name == 'pull_request' }} | |
env: | |
TARGET_BRANCH: ${{ github.base_ref }} | |
# transform "1.7.x" in "1.7" | |
run: | | |
echo "VERSION=`echo $TARGET_BRANCH | perl -pe 's|^([\d.]+)(?:\.x)?$|\1|'`" >> $GITHUB_ENV; | |
- name: Find version from branch name (push) | |
if: ${{ github.event_name != 'pull_request' }} | |
env: | |
TARGET_BRANCH: ${{ github.ref }} | |
# transform "refs/heads/1.7.x" in "1.7" | |
run: | | |
echo "VERSION=`echo $TARGET_BRANCH | perl -pe 's|^.+/([^/]+?)(?:\.x)?$|\1|'`" >> $GITHUB_ENV; | |
- name: Ensure the version is coherent | |
run: | | |
VERSION_FORMAT='^([0-9]+\.)*[0-9]+$' | |
if [[ ! $VERSION =~ $VERSION_FORMAT ]]; then | |
echo "::error::Version '$VERSION' is not a valid version!" | |
exit 1 | |
else | |
echo "Version: '$VERSION'" | |
fi | |
- name: Move content into the appropriate directory | |
run: | | |
[[ -d "src/content/$VERSION" ]] && rm -rf "src/content/$VERSION"; | |
mv _current "src/content/$VERSION" | |
- name: Build | |
env: | |
DEVDOCS_GITHUB_READ_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: cd src/ && hugo |