article: Added the draft version for the how to publish a component #170
Workflow file for this run
This file contains hidden or 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 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 | |
| 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: 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 |