Skip to content

Commit

Permalink
Merge pull request #1500 from EnterpriseDB/test/josh/auto-deploy-netl…
Browse files Browse the repository at this point in the history
…ify-draft

Label-triggered draft deploys

Former-commit-id: 2d480cf
  • Loading branch information
josh-heyer authored Aug 9, 2021
2 parents ba10a77 + 3accf4b commit b3c5a0c
Show file tree
Hide file tree
Showing 9 changed files with 629 additions and 268 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/deploy-draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Deploy branch draft on Netlify
on:
pull_request:
types: [labeled, opened, synchronize]

concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true

jobs:
build-deploy:
if: |
(github.event.action == 'labeled' && github.event.label.name == 'deploy') ||
(github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'deploy'))
runs-on: ubuntu-latest
steps:
- name: inject slug/short variables
uses: rlespinasse/[email protected]

- name: compose a name for the build environment
run: echo "BUILD_ENV_NAME=pr-${{ github.event.number }}-${{ env.GITHUB_HEAD_REF_SLUG }}" >> $GITHUB_ENV

- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 # fetch whole repo so git-restore-mtime can work

- name: Adjust file watchers limit
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

- uses: actions/setup-node@v1
with:
node-version: '14.x'

# ref: https://github.com/actions/cache/blob/main/examples.md#node---yarn
- name: Get yarn cache directory
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Checking Yarn cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Yarn install
run: npx yarn install --immutable
env:
NODE_ENV: ${{ secrets.NODE_ENV }}

- name: Checking Gatsby cache
id: gatsby-cache-build
uses: actions/cache@v2
with:
path: |
public
.cache
key: ${{ runner.os }}-gatsby-build-draft-${{ github.head_ref }}

- name: Fix mtimes
run: yarn fix-mtimes --force

- name: Gatsby build
run: yarn build
env:
APP_ENV: staging
NODE_ENV: ${{ secrets.NODE_ENV }}
NODE_OPTIONS: --max-old-space-size=4096
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_INDEX_NAME: edb-docs-staging
INDEX_ON_BUILD: false

- name: Deploy to Netlify
id: netlify-deploy
uses: nwtgck/[email protected]
with:
publish-dir: './public'
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: ${{ github.event.pull_request.title }}
enable-commit-comment: false
github-deployment-environment: ${{ env.BUILD_ENV_NAME }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DEVELOP_SITE_ID }}

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,4 @@ Option 2: on GitHub

1. Edit a file on GitHub.
2. Submit changes as a PR on a new branch.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
"remark-stringify": "^8.1.1",
"semver-compare": "^1.0.0",
"to-vfile": "^6.1.0",
"typescript": "^4.1.3"
"typescript": "^4.1.3",
"yarn": "^1.22.10"
},
"repository": {
"type": "git",
Expand Down
783 changes: 522 additions & 261 deletions src/constants/product-stubs.js

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions src/templates/doc-stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from "../components";

export const query = graphql`
query ($nodeId: String!, $potentialLatestNodePath: String) {
query($nodeId: String!, $potentialLatestNodePath: String) {
mdx(id: { eq: $nodeId }) {
fields {
path
Expand Down Expand Up @@ -62,8 +62,13 @@ const determineCanonicalPath = (hasLatest, latestPath) => {
const DocTemplate = ({ data, pageContext }) => {
const { fields, body, tableOfContents } = data.mdx;
const { path, mtime } = fields;
const { pagePath, frontmatter, versions, githubFileLink, isIndexPage } =
pageContext;
const {
pagePath,
frontmatter,
versions,
githubFileLink,
isIndexPage,
} = pageContext;
const versionArray = makeVersionArray(versions, path);
const { version } = getProductAndVersion(path);
const pageMeta = {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { products } from "../constants/products";
import Icon from "../components/icon";

export const query = graphql`
query ($nodeId: String!, $potentialLatestNodePath: String) {
query($nodeId: String!, $potentialLatestNodePath: String) {
mdx(id: { eq: $nodeId }) {
fields {
path
Expand Down
2 changes: 1 addition & 1 deletion src/templates/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { graphql } from "gatsby";

export const query = graphql`
query ($nodeId: String!) {
query($nodeId: String!) {
file(id: { eq: $nodeId }) {
internal {
content
Expand Down
2 changes: 1 addition & 1 deletion src/templates/learn-doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from "../components";

export const query = graphql`
query ($nodeId: String!) {
query($nodeId: String!) {
mdx(id: { eq: $nodeId }) {
fields {
path
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15295,6 +15295,11 @@ yargs@^16.1.0:
y18n "^5.0.5"
yargs-parser "^20.2.2"

yarn@^1.22.10:
version "1.22.10"
resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.22.10.tgz#c99daa06257c80f8fa2c3f1490724e394c26b18c"
integrity sha512-IanQGI9RRPAN87VGTF7zs2uxkSyQSrSPsju0COgbsKQOOXr5LtcVPeyXWgwVa0ywG3d8dg6kSYKGBuYK021qeA==

yauzl@^2.4.2:
version "2.10.0"
resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9"
Expand Down

0 comments on commit b3c5a0c

Please sign in to comment.