Publish preview on netlify #4402
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 (c) 2020 Red Hat, Inc. | |
# This program and the accompanying materials are made | |
# available under the terms of the Eclipse Public License 2.0 | |
# which is available at https://www.eclipse.org/legal/epl-2.0/ | |
# | |
# SPDX-License-Identifier: EPL-2.0 | |
# | |
# NOTE: Because this worklow is using secrets, it cannot run directly on a pull-request workflow, which is running in the context of the forked repository. | |
name: Publish preview on netlify | |
on: | |
workflow_run: | |
workflows: | |
- "Build and validate pull request" | |
types: | |
- completed | |
jobs: | |
publish: | |
name: Publish preview on netlify | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Download doc-content artifact | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
workflow: ${{ github.event.workflow_run.workflow_id }} | |
name: doc-content | |
path: content | |
- name: Set PR_NUMBER and PR_SHA variables | |
id: vars | |
run: | | |
echo "pr_number=$(<content/PR_NUMBER)" >> $GITHUB_OUTPUT | |
echo "pr_sha=$(<content/PR_SHA)" >> $GITHUB_OUTPUT | |
- name: Publish preview netlify | |
uses: netlify/actions/cli@master | |
id: netlify-publish | |
with: | |
args: deploy --dir=content/build/site --functions=functions | |
env: | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
- name: Update status comment | |
uses: actions-cool/maintain-one-comment@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body: | | |
🎊 Navigate the preview: ${{ steps.netlify-publish.outputs.NETLIFY_URL }} 🎊 | |
<!-- Sticky Pull Request Comment --> | |
body-include: "<!-- Sticky Pull Request Comment -->" | |
number: ${{ steps.vars.outputs.pr_number }} |