Metadata attributes apply as well as elements #84
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 and deploy | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: set target output | |
if: ${{ github.event_name == 'pull_request' }} | |
run: | | |
echo "TARGET_BRANCH=${{ github.event.pull_request.head.ref }}-build" >> $GITHUB_ENV | |
GH_LINK="${{ github.server_url }}/${{ github.repository }}/blob/${{ github.event.pull_request.head.ref }}-build/" | |
GH_LINK="${GH_LINK//':'/'%3A'}" | |
GH_LINK="${GH_LINK//'/'/'%2F'}" | |
echo "GH_LINK=${GH_LINK}" >> $GITHUB_ENV | |
- name: set target as gh-pages for main | |
if: ${{ github.event_name == 'push' }} | |
run: echo "TARGET_BRANCH=gh-pages" >> $GITHUB_ENV | |
- name: no push target if forked | |
if: github.event.pull_request.base.repo.clone_url != github.event.pull_request.head.repo.clone_url | |
run: echo "TARGET_BRANCH=" >> $GITHUB_ENV | |
- name: build with ant | |
working-directory: ./spec | |
run: ant build | |
- name: git push | |
working-directory: ./spec/build | |
if: env.TARGET_BRANCH != '' | |
run: | | |
cp -a ../../.git ./ | |
git symbolic-ref HEAD refs/heads/${{ env.TARGET_BRANCH }} | |
git fetch origin ${{ env.TARGET_BRANCH }} && git reset origin/${{ env.TARGET_BRANCH }} | |
git config user.name "CI (${{ github.actor }})" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add -A . | |
git commit -m "Deploy ${{ env.TARGET_BRANCH }}: ${{ github.sha }}" | |
git push --set-upstream origin ${{ env.TARGET_BRANCH }} | |
- name: set target output | |
if: github.event_name == 'pull_request' && env.TARGET_BRANCH != '' | |
working-directory: ./spec/build | |
run: | | |
wget -O diff.html "https://services.w3.org/htmldiff?doc1=https%3A%2F%2Fw3c.github.io%2Fttml2%2F&doc2=${{ env.GH_LINK }}index.html%3Fraw%3Dtrue" | |
echo "<script src=\"https://raw.githubusercontent.com/w3c/htmldiff-nav/main/index.js\"></script>" >> diff.html | |
- name: push diff | |
if: github.event_name == 'pull_request' && env.TARGET_BRANCH != '' | |
working-directory: ./spec/build | |
run: | | |
git add diff.html | |
git commit -m "Added diff: ${{ github.sha }}" | |
git push | |
- name: push comment for built | |
if: github.event_name == 'pull_request' && env.TARGET_BRANCH != '' | |
uses: actions/github-script@v4 | |
with: | |
script: | | |
github.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: ${{ github.event.pull_request.number }}, | |
body: "[Preview](https://htmlpreview.github.io/?${{ github.server_url }}/${{ github.repository }}/blob/${{ env.TARGET_BRANCH }}/index.html) | [diff](https://htmlpreview.github.io/?${{ github.server_url }}/${{ github.repository }}/blob/${{ env.TARGET_BRANCH }}/diff.html) for ${{ github.event.pull_request.head.sha }}" | |
}) | |