Add browsable site map #453
Workflow file for this run
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: build-pr | |
on: | |
pull_request_target: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: 'npm' | |
- name: Install Node modules | |
run: npm install | |
- name: Eleventy | |
run: | | |
cp -f _data/site.json /tmp/site.json | |
jq '.base_url = "https://igalia.github.io"' \ | |
/tmp/site.json > _data/site.json | |
npx eleventy \ | |
--output='_site/${{ github.head_ref }}' \ | |
--pathprefix='/wpewebkit.org/${{ github.head_ref }}' | |
LC_TIME=C date > '_site/${{ github.head_ref }}/.stamp' | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./_site | |
keep_files: true | |
- name: Add deploy link | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const { data: pr } = await github.rest.pulls.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number, | |
}); | |
// Site preview link already added. | |
const marker = '\n\n----\n\nSite preview: '; | |
if (pr.body && pr.body.indexOf(marker) != -1) | |
return; | |
await github.rest.pulls.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: pr.number, | |
body: pr.body + marker + 'https://igalia.github.io/wpewebkit.org/${{ github.head_ref }}/', | |
}); |