diff --git a/.github/workflows/www.yml b/.github/workflows/www.yml new file mode 100644 index 0000000..32599c7 --- /dev/null +++ b/.github/workflows/www.yml @@ -0,0 +1,167 @@ +name: Update API docs + +on: + # Trigger on push to branche `master`. + push: + branches: [ master ] + # Trigger on pull request events for PRs that have `master` as their target branch + pull_request: + branches: [ master ] + + # Allow running the workflow manually + workflow_dispatch: + +defaults: + run: + # GitHub Actions adds `errexit` and `pipefail` by default, but we add `xtrace` + # to improve debugging some of the longer scripts. + shell: /bin/bash -o errexit -o pipefail -o xtrace {0} + +jobs: + main: + runs-on: ubuntu-20.04 + + steps: + # Create a cache invalidation key based on the current year + week. + # This way, packages will be checked for updates once every week. + - name: Get Date + id: get-date + run: echo "::set-output name=date::$(/bin/date -u "+%Y%W")" + + - name: Cache apt packages + id: cache-apt + uses: actions/cache@v2 + with: + path: /var/cache/apt/archives + # The trailing number serves as a version flag that can be incremented + # to invalidate the cache after changing the list of packages. + key: ${{ github.workflow }}-${{ runner.os }}-${{ steps.get-date.outputs.date }}-apt-3 + + - name: Download apt packages + if: steps.cache-apt.outputs.cache-hit != 'true' + run: | + sudo apt-get update + sudo apt-get install --download-only -y --no-install-recommends \ + ikiwiki \ + asciidoc \ + imagemagick \ + perlmagick \ + luarocks \ + cmake \ + libxcb-cursor-dev \ + libxcb-randr0-dev \ + libxcb-xtest0-dev \ + libxcb-xinerama0-dev \ + libxcb-shape0-dev \ + libxcb-util0-dev \ + libxcb-keysyms1-dev \ + libxcb-icccm4-dev \ + libxdg-basedir-dev \ + libstartup-notification0-dev \ + libxcb-xkb-dev \ + libxkbcommon-dev \ + libxkbcommon-x11-dev \ + gir1.2-pango-1.0 \ + xutils-dev \ + libgirepository1.0-dev \ + lua-discount + + - name: Install downloaded packages + run: | + sudo dpkg -i /var/cache/apt/archives/*.deb + + - name: Cache luarocks + id: cache-luarocks + uses: actions/cache@v2 + with: + path: /tmp/luarocks + key: ${{ github.workflow }}-${{ runner.os }}-luarocks-3.5.0 + + - name: Install fresh Luarocks + if: steps.cache-luarocks.outputs.cache-hit != 'true' + run: | + wget -O /tmp/luarocks.tar.gz https://github.com/luarocks/luarocks/archive/v3.5.0.tar.gz + mkdir /tmp/luarocks + tar -xf /tmp/luarocks.tar.gz -C /tmp/luarocks --strip-components=1 + cd /tmp/luarocks + ./configure + make build + sudo make install + + - name: Install cached Luarocks + if: steps.cache-luarocks.outputs.cache-hit == 'true' + run: | + cd /tmp/luarocks + sudo make install + + - name: Install rocks + run: | + sudo -H luarocks install lgi + sudo -H luarocks install ldoc + + - name: Install mdl + run: | + sudo gem install mdl -v 0.9.0 + + - uses: actions/checkout@v2 + + - name: Create Build Environment + run: cmake -E make_directory -B "${{ github.workspace }}/build" + + - name: Get Pull Request Number + id: pr + run: echo "::set-output name=pull_request_number::$(gh pr view --json number -q .number || echo "")" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get AwesomeWM + env: + APIDOC_TOKEN: ${{ secrets.AWESOME_ROBOT_TOKEN || github.token }} + run: | + set -e + git clone \ + https://${APIDOC_TOKEN}@github.com/awesomeWM/awesomeWM.github.io \ + "${{ github.workspace }}/build" 2>&1 | sed "s/$APIDOC_TOKEN/APIDOC_TOKEN/g" + if [ "${{ github.event_name }}" != 'pull_request' ]; then + branch="${{ github.head_ref || github.ref_name }} " + else + branch="pr-${{ steps.pr.outputs.pull_request_number }}" + fi + if [ "$branch" != master ]; then + cd "${{ github.workspace }}/build" + if ! git checkout -b "$branch" "origin/$branch"; then + git checkout -b "$branch" + fi + cd - + fi + + - name: Build website + run: | + cd "${{ github.workspace }}" + PKG_CONFIG_PATH="$HOME/install/lib/pkgconfig" make build_for_gh_actions + mdl --git-recurse . + + - name: Publish website + if: github.event_name != 'pull_request' + env: + APIDOC_TOKEN: ${{ secrets.AWESOME_ROBOT_TOKEN || github.token }} + run: | + set -e + commit_hash=$(git rev-parse --short HEAD) + cd "${{ github.workspace }}/build" + git config user.name "awesome-robot on GH Actions" + git config user.email "awesome-robot@users.noreply.github.com" + git add --all . + NL=$'\n' + git commit -m "Update from GH Actions for awesome-www@${commit_hash}${NL}${NL}Commits: ${{ github.event.pull_request.commits_url }}${NL}Build URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" + git --no-pager show --stat + git push origin "$(git symbolic-ref --quiet HEAD)" 2>&1 | sed "s/$APIDOC_TOKEN/APIDOC_TOKEN/g" + + # Purge CloudFlare cache. + curl -X DELETE "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE/purge_cache" \ + -H "X-Auth-Email: $CLOUDFLARE_AUTH_EMAIL" \ + -H "X-Auth-Key: $CLOUDFLARE_AUTH_KEY" \ + -H "Content-Type: application/json" \ + --data '{"purge_everything":true}' + +# vim: filetype=yaml:expandtab:shiftwidth=2:tabstop=2 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 61118a6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,109 +0,0 @@ -dist: xenial -language: minimal -branches: - only: - - master -env: - global: - - BUILD_WEB=/tmp/build-web - - secure: dMquVRuM4Wi/N3oZJaNIWSW5mpehxVuzDiDnC51OwfMtdNfdyWV7qKJQY44MjbveuyQd7eA/AuTLE+loaAFxiRfBXl2yI5NkAOrJwbbDyw/lAN9Og2FmNi+QLaTsNhpbYZ4zaUNEEqRWs9gIajGaXcWdO/HNYiKHHrk7+XXNDeM= - # CLOUDFLARE_AUTH_EMAIL/CLOUDFLARE_AUTH_KEY - - secure: JYKSA0crhIfgE7l51aF+qYr4JERLU3hXWRzKSmwuBi4uZzNxWfAm1hQ8qJ4+TTIIjJpr4dceVLdXRZDvX5B83hP8W4m4eoRp98IqwLinS5plB86Kv/C53vYGaMIaE+3u0EdehRgpSIN+2qmAUTNoQkFZsZh1Ok4vaN3QZaE2+f8= - # CLOUDFLARE_ZONE - - secure: LYV3F3ink6p8XfR2rjCcYDfTDSK22QRU4kYK4e77t42e3zky/tbiNZcJsrq9J5FwNEBZXDLxuXsgeEza3+x6N0uxjBIdopuEullL5jf5WRISxUja2wplOgCa8RC8CIvWyZOsbtw8UWJvbCyjwUXPT8q9sUT1U+KhYSuqVMo32GI= -addons: - apt: - packages: - - ikiwiki - - asciidoc - - imagemagick - - perlmagick - - luarocks - - cmake - - libxcb-cursor-dev - - libxcb-randr0-dev - - libxcb-xtest0-dev - - libxcb-xinerama0-dev - - libxcb-shape0-dev - - libxcb-util0-dev - - libxcb-keysyms1-dev - - libxcb-icccm4-dev - - libxdg-basedir-dev - - libstartup-notification0-dev - - libxcb-xkb-dev - - libxkbcommon-dev - - libxkbcommon-x11-dev - - gir1.2-pango-1.0 - # Dependencies for xcb-util-xrm - - xutils-dev - # Dependencies for lgi - - libgirepository1.0-dev - - lua-discount - -# Clone the awesomeWM.github.io repo before building, because we need the -# working copy to be there for updating already. -before_install: - - | - if [ -n "$GH_APIDOC_TOKEN" ]; then - set -e - git clone \ - https://${GH_APIDOC_TOKEN}@github.com/awesomeWM/awesomeWM.github.io \ - "$BUILD_WEB" 2>&1 | sed "s/$GH_APIDOC_TOKEN/GH_APIDOC_TOKEN/g" - if [ "$TRAVIS_PULL_REQUEST" = false ]; then - branch="$TRAVIS_BRANCH" - else - branch="pr-$TRAVIS_PULL_REQUEST" - fi - if [ "$branch" != master ]; then - cd $BUILD_WEB - if ! git checkout -b "$branch" "origin/$branch"; then - git checkout -b "$branch" - fi - cd - - fi - fi - -install: - # xcb-util-xrm is not available in Ubuntu Ancient - - (cd /tmp && git clone --recursive https://github.com/Airblader/xcb-util-xrm.git && cd xcb-util-xrm && ./autogen.sh --prefix=$HOME/install && make && make install) - - - travis_retry luarocks --local install ldoc - - luarocks path --bin - - eval `luarocks path --bin` - # Of course Ubuntu's Luarocks version is too old for --bin - - PATH="$PATH:$HOME/.luarocks/bin" - - # lgi is too old - - travis_retry luarocks --local install lgi - - - gem install mdl -v 0.9.0 - -after_install: - - luarocks --local list --porcelain | column -t -s $'\t' - -script: - - PKG_CONFIG_PATH="$HOME/install/lib/pkgconfig" make build_for_travis - - mdl --git-recurse . - -after_success: - - | - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then exit 0; fi - if [ -n "$GH_APIDOC_TOKEN" ]; then - set -e - commit_hash=$(git rev-parse --short HEAD) - cd $BUILD_WEB - git config user.name "awesome-robot on Travis CI" - git config user.email "awesome-robot@users.noreply.github.com" - git add --all . - NL=$'\n' - git commit -m "Update from Travis for awesome-www@${commit_hash}${NL}${NL}Commits: https://github.com/awesomeWM/awesome-www/compare/${TRAVIS_COMMIT_RANGE/.../..}${NL}Build URL: https://travis-ci.com/awesomeWM/awesome-www/builds/${TRAVIS_BUILD_ID}" - git --no-pager show --stat - git push origin "$(git symbolic-ref --quiet HEAD)" 2>&1 | sed "s/$GH_APIDOC_TOKEN/GH_APIDOC_TOKEN/g" - - # Purge CloudFlare cache. - curl -X DELETE "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE/purge_cache" \ - -H "X-Auth-Email: $CLOUDFLARE_AUTH_EMAIL" \ - -H "X-Auth-Key: $CLOUDFLARE_AUTH_KEY" \ - -H "Content-Type: application/json" \ - --data '{"purge_everything":true}' - fi diff --git a/Makefile b/Makefile index 4018704..3c769cb 100644 --- a/Makefile +++ b/Makefile @@ -34,10 +34,10 @@ manpages: do asciidoc -a icons -b xhtml11 -o ../../html/doc/manpages/`basename $${manpage} .txt`.html $$manpage || exit 1; \ done -build_for_travis: all -build_for_travis: BUILD_WEB?=/tmp/awesome-build-web -build_for_travis: ASCIIDOC_ICONS_DIR?=/usr/share/asciidoc/icons -build_for_travis: +build_for_gh_actions: all +build_for_gh_actions: BUILD_WEB?=/tmp/awesome-build-web +build_for_gh_actions: ASCIIDOC_ICONS_DIR?=/usr/share/asciidoc/icons +build_for_gh_actions: test -d "$(ASCIIDOC_ICONS_DIR)" rsync -PaOvz --delete --exclude=.git --chmod=u=rwX,g=rwX,o=rX,Dg+s --exclude src html/ \ "$(BUILD_WEB)"