Skip to content

Merge pull request #79 from dokku/revert-78-dependabot/docker/_build/… #81

Merge pull request #79 from dokku/revert-78-dependabot/docker/_build/…

Merge pull request #79 from dokku/revert-78-dependabot/docker/_build/… #81

Workflow file for this run

---
name: 'docs'
# yamllint disable-line rule:truthy
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Cloning repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "Setup python 3.10"
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Generate documentation
env:
BOT_GITHUB_USERNAME: ${{ secrets.HOMEBREW_GITHUB_USERNAME }}
BOT_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
SITE_FOLDER: tutorials
run: |
echo "====> Authenticating to repository"
git config --global user.name 'Dokku Bot'
git config --global user.email [email protected]
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update -q
sudo apt install gh -y -q
gh auth login --with-token <<<"$BOT_GITHUB_API_TOKEN"
echo "====> Fetching latest docs"
rm -rf tmp
git clone -q https://github.com/dokku/docs.git tmp
echo "----> Generating docker image"
make docs-build-image
echo "----> Generating $SITE_FOLDER"
make docs-build
if [[ -n "$GITHUB_ACTION" ]]; then
sudo chown -R "$(whoami)" $SITE_FOLDER
fi
rm -rf "tmp/$SITE_FOLDER"
mv "$SITE_FOLDER" "tmp/$SITE_FOLDER"
if [[ "$(git -C tmp ls-files -dmo)" == "$SITE_FOLDER/sitemap.xml.gz" ]]; then
echo " ! No doc changes found"
git -C tmp checkout -- "$SITE_FOLDER/sitemap.xml.gz"
else
echo "====> Pushing $SITE_FOLDER"
git -C tmp add .
git -C tmp commit -m "chore: regenerate $SITE_FOLDER"
if [[ -n "$BOT_GITHUB_USERNAME" ]] && [[ -n "$BOT_GITHUB_API_TOKEN" ]]; then
git -C tmp remote set-url origin "https://$BOT_GITHUB_USERNAME:[email protected]/dokku/docs.git"
fi
git -C tmp push origin master
fi