Skip to content

Commit

Permalink
ci: added logic for backport PRs (#1501) (#1502)
Browse files Browse the repository at this point in the history
* ci: added logic for backport PRs

* ci: fixed backport yaml issue

* ci: fixed backport yaml issue

* ci: fixed backport yaml issue

* ci: fixed backport yaml issue

* ci: fixed backport yaml issue

* ci: fixed backport yaml issue

* ci: fixed backport yaml issue

* ci: fixed backport yaml issue

* ci: fixed backport yaml issue

* ci: fixed backport yaml issue

* ci: fixed backport yaml issue

* docs: updated README with Netlify steps

(cherry picked from commit 913a118)

Co-authored-by: Karl Cardenas <karl@spectrocloud.com>
  • Loading branch information
github-actions[bot] and karl-cardenas-coding committed Aug 30, 2023
1 parent 6b8a0d1 commit 8eab44f
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 8 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true


jobs:
run-ci:
runs-on: ubuntu-latest
Expand All @@ -20,6 +21,27 @@ jobs:
# Because this step is part of the critical path, omission of this step will result in remaining CI steps not gettinge executed.
# As of 8/8/2022 there is now way to enforce this beahvior in GitHub Actions CI.
- run: exit 0

run-test:
name: Test
needs: [run-ci]
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3


- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'

- run: npm ci

- name: Test
run: npm run test

vale:
# Image Optimizer docs: https://github.com/calibreapp/image-actions
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ env:
GATSBY_ALGOLIA_SEARCH_KEY: ${{ secrets.DEV_GATSBY_ALGOLIA_SEARCH_KEY }}
GATSBY_ALGOLIA_APP_ID: ${{ secrets.DEV_GATSBY_ALGOLIA_APP_ID }}
ALGOLIA_ADMIN_KEY: ${{ secrets.DEV_ALGOLIA_ADMIN_KEY }}
GATSBY_MENDABLE_API_KEY: ${{ secrets.GATSBY_MENDABLE_API_KEY }}
NETLIFY_PREVIEW: false
# The GATSBY_FULLSTORY_ORGID is removed so that preview builds don't get recorded in FullStory

concurrency:
group: preview-${{ github.ref }}
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/version-branch-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- 'version-*'
pull_request:
branches:
- 'version-*'

concurrency:
group: version-${{ github.ref }}
Expand Down Expand Up @@ -31,13 +34,6 @@ jobs:
- run: npm ci


- name: Omit Netlify Preview
run: |
cat > netlify.toml
[build]
ignore = "exit 0"
<<EOF
- name: Build
run: |
make build
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ vale/styles/Google/
vale/styles/write-good/
.idea/
link_report.*
.vscode/
*-creds.tape
palette-docs.pdf


# Local Netlify folder
.netlify
# @netlify/plugin-gatsby ignores start
netlify/functions/gatsby
# @netlify/plugin-gatsby ignores end
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,11 @@ make verify-url-links-local
An auto generated spreedsheet is created with the name **link_report.csv**. To find broken URLs filter by the status code column. Anything with a status code not in the `200` range or with the state "broken" should be inspected.
## Netlify Previews
By default Netlify previews are enabled for pull requests. However, some branches do not require Netlify previews. In the [netlify.toml](./netlify.toml) file, a custom script is used to determine if a Netlify preview should be created. The script is located in the [scripts/netlify.sh](./scripts/netlify.sh) file. If you need to disable Netlify previews for a branch, add the branch name to the `allowed_branches` variable in the [scripts/netlify.sh](./scripts/netlify.sh) file.
### Cron Job
Every Monday at 6 AM UTC a GitHub Actions cron job is triggered. The cron job logic can be found in the file [url-checks.yaml](.github/workflows/url-checks.yaml). The core logic resides in [url-checker.sh](/scripts/url-checker.sh). The Slackbot application **Docs bot** is used to post the messages to the `#docs` channel.
Expand Down
4 changes: 4 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[build]
ignore = "./scripts/netlify.sh"
command = "npm run build"

33 changes: 33 additions & 0 deletions scripts/netlify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# List of branches to NOT create a Netlify preview
# Master branch does not need a preview
# Release branches get a preview through docs-latest.spectrocloud.com
allowed_branches=("master" "release-*")

echo "Branch name: $HEAD"

# Read the environment variable
branch_name=$HEAD

# Initialize a flag to check if the branch is not allowed
not_allowed=0

# Compare $HEAD against the list
for allowed in "${allowed_branches[@]}"
do
# Use double brackets and == for pattern matching
if [[ "$branch_name" == $allowed ]]; then
not_allowed=1
break
fi
done

# Exit accordingly
if [ $not_allowed -eq 1 ]; then
echo "Not allowed to create a Netlify preview"
exit 0
else
echo "Allowed to create a Netlify preview"
exit 1
fi

0 comments on commit 8eab44f

Please sign in to comment.