Skip to content

RHIDP-4896 Determining the permission policy configuration source #2728

RHIDP-4896 Determining the permission policy configuration source

RHIDP-4896 Determining the permission policy configuration source #2728

Workflow file for this run

# Copyright (c) 2023 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Build HTML preview of PR
on:
# /!\ Warning: using the pull_request_target event to be able to read secrets. But using this event without the cautionary measures described below
# may allow unauthorized GitHub users to open a “pwn request” and exfiltrate secrets.
# As recommended in https://iterative.ai/blog/testing-external-contributions-using-github-actions-secrets,
# we are adding an 'authorize' job that checks if the workflow was triggered from a fork PR. In that case, the "external" environment
# will prevent the job from running until it's approved manually by human intervention.
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- main
- rhdh-1.**
- 1.**.x
- release-1.**
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.event.pull_request.head.ref }}
cancel-in-progress: true
jobs:
authorize:
# The 'external' environment is configured with the odo-maintainers team as required reviewers.
# All the subsequent jobs in this workflow 'need' this job, which will require manual approval for PRs coming from external forks.
# see list of approvers in OWNERS file
environment:
${{ (github.event.pull_request.head.repo.full_name == github.repository ||
contains(fromJSON('["gazarenkov","jianrongzhang89","kadel","nickboldt","rm3l"]'), github.actor)) && 'internal' || 'external' }}
runs-on: ubuntu-latest
steps:
- name: approved
run: |
echo "✓"
adoc_build:
name: Ccutil Build For PR branch preview
runs-on: ubuntu-latest
needs: authorize
permissions:
contents: read
packages: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Setup environment
run: |
# update
sudo apt-get update -y || true
# install
sudo apt-get -y -q install podman && podman --version
echo "GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV
- name: Build guides and indexes
run: |
echo "Building PR ${{ github.event.pull_request.number }}"
build/scripts/build-ccutil.sh -b "pr-${{ github.event.number }}"
- name: Pull from origin before pushing (if possible)
run: |
/usr/bin/git pull origin gh-pages || true
# repo must be public for this to work
- name: Deploy
uses: peaceiris/actions-gh-pages@v4
# if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.RHDH_BOT_TOKEN }}
publish_branch: gh-pages
keep_files: true
publish_dir: ./titles-generated
- name: PR comment with doc preview, replacing existing comments with a new one each time
shell: bash
env:
GH_TOKEN: ${{ secrets.RHDH_BOT_TOKEN }}
run: |
PR_NUM="${{ github.event.number }}"
ORG_REPO="${{ github.repository_owner }}/${{ github.event.repository.name }}"
gh repo set-default "${ORG_REPO}"
# for a given PR, check for existing comments from rhdh-bot; select the last one (if more than one)
if [[ $(gh api "repos/${ORG_REPO}/issues/${PR_NUM}/comments" -q 'map(select(.user.login=="rhdh-bot"))|last|.id') ]]; then
# edit that comment:
gh pr comment ${PR_NUM} -R "${ORG_REPO}" --edit-last --body "Updated preview: https://redhat-developer.github.io/red-hat-developers-documentation-rhdh/pr-${PR_NUM}/ @ $(date "+%x %X")"
else
# or create a new one:
gh pr comment ${PR_NUM} -R "${ORG_REPO}" --body "Preview: https://redhat-developer.github.io/red-hat-developers-documentation-rhdh/pr-${PR_NUM}/"
fi