Skip to content

Commit 69f3b3e

Browse files
author
Gaurav Nelson
committed
Enable Netlify previews for all PRs
1 parent fcc95c9 commit 69f3b3e

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ git:
77
jobs:
88
include:
99
- stage: build
10-
name: "Build openshift-enterprise distro"
10+
name: "Build openshift-enterprise distro"
1111
before_install:
1212
- gem install asciidoctor
1313
- gem install asciidoctor-diagram
@@ -54,8 +54,14 @@ jobs:
5454
# - stage: automerge
5555
# if: env(PR_AUTHOR)=openshift-cherrypick-robot
5656
# script: bash ./automerge.sh
57+
- stage: netlify
58+
language: minimal
59+
if: branch IN (main, enterprise-4.11, enterprise-4.12)
60+
script:
61+
- chmod +x autopreview.sh && ./autopreview.sh
5762

5863
stages:
5964
- build
6065
- check-with-vale
6166
#- automerge
67+
- netlify

autopreview.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
#!/bin/bash
22
set -ev
33

4-
ALLOWED_USERS=("aireilly" "mburke5678" "vikram-redhat" "abrennan89" "ahardin-rh" "kalexand-rh" "adellape" "bmcelvee" "ousleyp" "lamek" "JStickler" "rh-max" "bergerhoffer" "sheriff-rh" "jboxman" "bobfuru" "aburdenthehand" "boczkowska" "Preeticp" "neal-timpe" "codyhoag" "apinnick" "bgaydosrh" "lmandavi" "maxwelldb" "pneedle-rh" "lbarbeevargas" "jeana-redhat" "RichardHoch" "johnwilkins" "sjhala-ccs" "mgarrellRH" "SNiemann15" "sfortner-RH" "jonquilwilliams" "ktania46" "wking" "
5-
jc-berger" "rishumehra" "iranzo" "abhatt-rh" "@mohit-sheth" "stoobie" "emarcusRH" "kquinn1204" "mikemckiernan" "skrthomas" "sagidlow" "rolfedh")
4+
#ALLOWED_USERS=("aireilly" "mburke5678" "vikram-redhat" "abrennan89" "ahardin-rh" "kalexand-rh" "adellape" "bmcelvee" "ousleyp" "lamek" "JStickler" "rh-max" "bergerhoffer" "sheriff-rh" "jboxman" "bobfuru" "aburdenthehand" "boczkowska" "Preeticp" "neal-timpe" "codyhoag" "apinnick" "bgaydosrh" "lmandavi" "maxwelldb" "pneedle-rh" "lbarbeevargas" "jeana-redhat" "RichardHoch" "johnwilkins" "sjhala-ccs" "mgarrellRH" "SNiemann15" "sfortner-RH" "jonquilwilliams" "ktania46" "wking" "
5+
#jc-berger" "rishumehra" "iranzo" "abhatt-rh" "@mohit-sheth" "stoobie" "emarcusRH" "kquinn1204" "mikemckiernan" "skrthomas" "sagidlow" "rolfedh")
66
USERNAME=${TRAVIS_PULL_REQUEST_SLUG::-15}
77
COMMIT_HASH="$(git rev-parse @~)"
88
mapfile -t FILES_CHANGED < <(git diff --name-only "$COMMIT_HASH")
99

1010
if [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then #to make sure it only runs on PRs and not all merges
11-
if [[ " ${ALLOWED_USERS[*]} " =~ " ${USERNAME} " ]]; then # to make sure it only runs on PRs from @openshift/team-documentation
12-
if [ "${TRAVIS_PULL_REQUEST_BRANCH}" != "master" ] ; then # to make sure it does not run for direct master changes
13-
if [[ " ${FILES_CHANGED[*]} " = *".adoc"* ]] || [[ " ${FILES_CHANGED[*]} " = *"_topic_map.yml"* ]] || [[ " ${FILES_CHANGED[*]} " = *"_distro_map.yml"* ]] ; then # to make sure this doesn't run for general modifications
11+
if [ "${TRAVIS_PULL_REQUEST_BRANCH}" != "main" ] ; then # to make sure it does not run for direct main changes
12+
if [[ " ${FILES_CHANGED[*]} " = *".adoc"* ]] || [[ " ${FILES_CHANGED[*]} " = *"_topic_map.yml"* ]] || [[ " ${FILES_CHANGED[*]} " = *"_distro_map.yml"* ]] ; then # to make sure this doesn't run for general modifications
13+
if [ "$USERNAME" != "openshift-cherrypick-robot" ] ; then # to make sure it doesn't run for USERNAME openshift-cherrypick-robot
1414
echo "{\"PR_BRANCH\":\"${TRAVIS_PULL_REQUEST_BRANCH}\",\"BASE_REPO\":\"${TRAVIS_REPO_SLUG}\",\"PR_NUMBER\":\"${TRAVIS_PULL_REQUEST}\",\"USER_NAME\":\"${USERNAME}\",\"BASE_REF\":\"${TRAVIS_BRANCH}\",\"REPO_NAME\":\"${TRAVIS_PULL_REQUEST_SLUG}\"}" > buildset.json
15-
curl -H 'Content-Type: application/json' --request POST --data @buildset.json "https://roomy-tungsten-cylinder.glitch.me"
15+
16+
curl -H 'Content-Type: application/json' --request POST --data @buildset.json "https://eoa6vg2jiwjbnh6.m.pipedream.net"
17+
1618
echo -e "\\n\\033[0;32m[✓] Sent request for building a preview.\\033[0m"
1719
else
18-
echo -e "\\n\\033[1;33m[!] No .adoc files modified, not building a preview.\\033[0m"
20+
echo -e "\\n\\033[0;32m[✓] Skipping preview build for openshift-cherrypick-robot.\\033[0m"
1921
fi
2022
else
21-
echo -e "\\n\\033[1;33m[!] Direct PR for master branch, not building a preview.\\033[0m"
23+
echo -e "\\n\\033[1;33m[!] No .adoc files modified, not building a preview.\\033[0m"
2224
fi
2325
else
24-
echo -e "\\n\\033[1;33m[!] ${USERNAME} is not a team member of @openshift/team-documentation, not building a preview.\\033[0m"
26+
echo -e "\\n\\033[1;33m[!] Direct PR for main branch, not building a preview.\\033[0m"
2527
fi
2628
else
2729
echo -e "\\n\\033[1;33m[!] Not a PR, not building a preview.\\033[0m"

0 commit comments

Comments
 (0)