Skip to content

Publish PR check

Publish PR check #462

#
# Copyright (c) 2021 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
#
name: Publish PR check
on:
workflow_run:
workflows: ["Build PR check"]
types:
- completed
jobs:
publish-pr:
name: publish pull request
runs-on: ubuntu-22.04
steps:
- name: download dist artifact
uses: dawidd6/action-download-artifact@v6
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: blog-content
path: _site
- name: PR number
uses: dawidd6/action-download-artifact@v6
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: pull-request-number
- name: Grab pull request number
run: |
pr_number=$(cat "PR_NUMBER")
if ! [[ "$pr_number" =~ ^[0-9]+$ ]]; then
echo "pr number invalid"
exit 1
fi
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV
- name: PR sha
uses: dawidd6/action-download-artifact@v6
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: pull-request-sha
- name: Grab pull request sha1
run: |
pr_sha=$(cat "PR_SHA")
echo "PR_SHA=$pr_sha" >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: publish
env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
run: |
npm install -g surge
export DEPLOY_DOMAIN=https://pr-check-${PR_NUMBER}-che-blog.surge.sh
echo "DEPLOY_DOMAIN=$DEPLOY_DOMAIN" >> $GITHUB_ENV
surge ./_site --domain $DEPLOY_DOMAIN
- name: 'Comment PR'
uses: actions/github-script@v7
with:
script: |
const { repo: { owner, repo } } = context;
await github.rest.repos.createCommitStatus({
owner,
repo,
sha: process.env.PR_SHA,
state: "success",
target_url: process.env.DEPLOY_DOMAIN,
description: "Browse PR check blog content live",
context: "surge"
})