Skip to content

test: add article to test workflows #114

test: add article to test workflows

test: add article to test workflows #114

name: Build preview for PR
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
env:
HUGO_BASEURL: "https://preview-developer.espressif.com/pr${{ github.event.pull_request.number }}/"
jobs:
build-preview:
runs-on: ubuntu-latest
steps:
- name: Install Hugo CLI
env:
HUGO_VERSION: 0.135.0
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Check out repo
uses: actions/checkout@v4
with:
submodules: recursive
- name: Extract PR URL for preview snippet
id: get-pr-url
run: |
PR_URL=$(jq -r '.pull_request.html_url' "$GITHUB_EVENT_PATH")
echo "PR_URL=$PR_URL" >> $GITHUB_ENV
PR_LINK_TEXT=${PR_URL#https://}
echo "PR_LINK_TEXT=$PR_LINK_TEXT" >> $GITHUB_ENV
- name: Append preview snippet to header file
run: |
PREVIEW_HTML="<p style='color: rgba(var(--color-primary-600), 1); text-align: center;'>
This site is a preview for <a href='${{ env.PR_URL }}' style='text-decoration: underline;'>${{ env.PR_LINK_TEXT }}</a>
</p>"
echo "$PREVIEW_HTML" >> layouts/partials/header/basic.html
- name: Build website with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: preview
HUGO_ENV: preview
run: |
hugo \
--baseURL ${{ env.HUGO_BASEURL }} \
--gc \
--minify
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: public-folder
path: ./public
- name: Calculate checksums for website files
run: |
cd public
find . -type f -exec sha256sum {} + | awk '{print $2, $1}' | sort > ../checksums-ci.txt
- name: Upload checksums to artifacts
uses: actions/upload-artifact@v4
with:
name: checksums-ci
path: checksums-ci.txt
- name: Create PR number file
run: echo "${{ github.event.pull_request.number }}" > pr-num.txt
- name: Upload PR number artifact
uses: actions/upload-artifact@v4
with:
name: pr-num
path: pr-num.txt