I need to provide a GitHub workflow for a help documentation written using the mdBook utility, where mdBook produces artifacts into a book directory.
After moving these artifacts to the top of my local Ubuntu repository, I would then commit the local repository changes to a particular GitHub branch.
I’ve tried that:
mv -f book .
rm -rf book
I get:
mv: ‘book’ and ‘./book’ are the same file
I’ve also tried that:
mv -f book ..
rm -rf book
It works, but I get nothing with this (I lose all files).
I have tried cp -r book <something like "." or "..">, but it did not go either.
I do not think I can try using / or ~ as a copy destination because the working repository is probably under another directory.
Here’s the full workflow:
name: Build
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
tags:
description: 'Build'
required: false
type: boolean
environment:
description: 'Environment to run tests against'
type: environment
required: true
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install mdbook CLI
run: cargo install mdbook --version ~0.4
- name: Build book
run: mdbook build
- name: Git commit report
run: |
mv -f book .
rm -rf book
# Git commit
git config --global user.name '<username>'
git config --global user.email '<e-mail>'
git switch -C live
git rm -r .github src theme .gitignore book.toml
git add .
git commit -m "Automated report"
git push origin -f live
>Solution :
You are trying to move the folder book to . – where it actually is already.
You want mv -f book/* . (move all the files inside book to .)