Announce sponsor #1147
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
# Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) | |
# | |
# SPDX-License-Identifier: BSD-2-Clause | |
--- | |
name: PR | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
jobs: | |
snapshot: | |
name: "Static snapshot" | |
runs-on: 'ubuntu-latest' | |
outputs: | |
linkchecker_failed: ${{ steps.linkchecker_status.outputs.linkchecker_failed }} | |
validator_failed: ${{ steps.validator_status.outputs.validator_failed }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: ./.github/actions/gen_static_website | |
id: 'gen_static_website' | |
- name: Check status of linkchecker | |
id: linkchecker_status | |
run: | | |
if [ -e ".linkchecker_failed" ]; then | |
echo "::set-output name=linkchecker_failed::true" | |
else | |
echo "::set-output name=linkchecker_failed::false" | |
fi | |
- name: Fix up linkchecker log paths | |
run: sed -i 's|/github/workspace/snapped_site/localhost||g' snapped_site/localhost/pr_checks/linkchecker.html | |
- name: HTML5 Validator | |
id: validate | |
uses: Cyb3r-Jak3/html5validator-action@v0.4.3 | |
with: | |
root: snapped_site/localhost | |
format: text | |
extra: --blacklist pr_checks | |
continue-on-error: true | |
- name: Check status of HTML5 validator | |
id: validator_status | |
run: | | |
if [ "${{ steps.validate.outputs.result }}" -eq "0" ]; then | |
echo "::set-output name=validator_failed::false" | |
else | |
echo "::set-output name=validator_failed::true" | |
fi | |
- name: Fix up HTML5 validator log paths | |
run: | | |
output="snapped_site/localhost/pr_checks/validator.log" | |
# Make some very dodgey HTML, so we can get nicer output | |
echo "<html><body><p>" > "$output" | |
sed 's|/github/workspace/snapped_site/localhost||g' log.log \ | |
| sed "s|'ERROR:|</p><p>ERROR:|g" \ | |
| sed "s|', '|<br />|g" \ | |
>> "$output" | |
echo "</p></body></html>" >> "$output" | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} | |
external_repository: seL4/website_pr_hosting | |
publish_branch: PR_${{ github.event.number }} | |
publish_dir: ./snapped_site | |
linkchecker: | |
name: "Link checker" | |
runs-on: 'ubuntu-latest' | |
needs: snapshot | |
continue-on-error: true | |
steps: | |
- name: show linkchecker status | |
run: | | |
if ${{ needs.snapshot.outputs.linkchecker_failed }}; then | |
exit 1 | |
fi | |
exit 0 | |
htmlvalidator: | |
name: "HTML5 Validator" | |
runs-on: 'ubuntu-latest' | |
needs: snapshot | |
continue-on-error: true | |
steps: | |
- name: show validator status | |
run: | | |
if ${{ needs.snapshot.outputs.validator_failed }}; then | |
exit 1 | |
fi | |
exit 0 | |
commenter: | |
name: "Report results as comment" | |
runs-on: 'ubuntu-latest' | |
needs: snapshot | |
steps: | |
# TODO: in the future, when this issue is resolved: https://github.com/peaceiris/actions-gh-pages/issues/348, the link | |
# generated should be for the commit itself, not just the tip. | |
- name: Build message | |
run: | | |
echo "Preview your changes [here](https://htmlpreview.github.io/?https://github.com/seL4/website_pr_hosting/blob/PR_${{ github.event.number }}/localhost/index.html)" > msg.txt | |
if ${{ needs.snapshot.outputs.linkchecker_failed }}; then | |
echo "" >> msg.txt | |
echo "The link checker found some issues! Review them [here](https://htmlpreview.github.io/?https://github.com/seL4/website_pr_hosting/blob/PR_${{ github.event.number }}/localhost/pr_checks/linkchecker.html)" >> msg.txt | |
fi | |
if ${{ needs.snapshot.outputs.validator_failed }}; then | |
echo "" >> msg.txt | |
echo "The HTML5 validator found some issues! Review them [here](https://htmlpreview.github.io/?https://github.com/seL4/website_pr_hosting/blob/PR_${{ github.event.number }}/localhost/pr_checks/validator.log)" >> msg.txt | |
fi | |
export MSG=$(cat msg.txt) | |
# The following replaces newlines with the string '\n' for the JS call further below | |
MSG="${MSG//$'\n'/'\n'}" | |
echo "MSG=$MSG" >> $GITHUB_ENV | |
- name: Print message | |
run: | | |
echo "$MSG" | |
- name: Leave comment with link to site, and results of checks | |
uses: actions/github-script@v3 | |
if: github.event_name == 'pull_request' | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
github.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: "${{ env.MSG }}" | |
}) |