Skip to content

Commit

Permalink
chore: Add netlify preview build via github actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Feb 8, 2025
1 parent c6cad69 commit 9eedd5f
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 13 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
with:
tags: toxchat/toktok.github.io:latest
outputs: type=docker
- name: Extract toktok-site directory from docker image
run: docker run --rm --entrypoint tar toxchat/toktok.github.io:latest -C /home/builder/build -c toktok-site | tar -x
- name: Upload toktok-site to artifacts
- name: Extract _site directory from docker image
run: docker run --rm --entrypoint tar toxchat/toktok.github.io:latest -C /home/builder/build -c _site | tar -x
- name: Upload _site to artifacts
uses: actions/upload-artifact@v4
with:
name: toktok-site
path: toktok-site
name: _site
path: _site
if-no-files-found: error
6 changes: 3 additions & 3 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ jobs:
with:
tags: toxchat/toktok.github.io:latest
outputs: type=docker
- name: Extract toktok-site directory from docker image
run: docker run --rm --entrypoint tar toxchat/toktok.github.io:latest -C /home/builder/build -c toktok-site | tar -x
- name: Extract _site directory from docker image
run: docker run --rm --entrypoint tar toxchat/toktok.github.io:latest -C /home/builder/build -c _site | tar -x
- name: Set-up Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: toktok-site
path: _site
- name: Deploy GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ concurrency:
jobs:
release:
uses: TokTok/ci-tools/.github/workflows/release-drafter.yml@master

netlify:
uses: TokTok/ci-tools/.github/workflows/netlify.yml@master
with:
dockerfile: Dockerfile
path: /home/builder/build
secrets:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
58 changes: 58 additions & 0 deletions .reviewable/completion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// jshint esversion: 6

// This code will check that the pull request has been approved via GitHub review approval by a
// minimum number of reviewers and by all assignees, and that no changes were requested by any
// reviewers. Only reviewers with write access to the repository are considered.
//
// This is very similar to GitHub's built-in branch protection option to require pull request
// reviews before merging, but allows for much more flexibility and customization.

// dependencies: lodash4

// The number of approvals required to merge.
let numApprovalsRequired = 1;

const approvals = review.pullRequest.approvals;

let numApprovals = _.filter(approvals, (x) => x === 'approved').length;
const numRejections = _.filter(approvals, (x) => x === 'changes_requested').length;

const discussionBlockers = _(review.discussions)
.filter((x) => !x.resolved)
.flatMap('participants')
.filter((x) => !x.resolved)
.map(user => _.pick(user, 'username'))
.value();

let pendingReviewers = _(discussionBlockers)
.map(user => _.pick(user, 'username'))
.concat(review.pullRequest.requestedReviewers)
.value();

const required = _.map(review.pullRequest.assignees, 'username');
_.pull(required, review.pullRequest.author.username);
if (required.length) {
numApprovalsRequired = _.max([required.length, numApprovalsRequired]);
numApprovals =
(_(approvals).pick(required).filter('approved').size()) +
_.min([numApprovals, numApprovalsRequired - required.length]);
pendingReviewers = _(required)
.reject(username => approvals[username] === 'approved')
.reject(username => pendingReviewers.length && approvals[username])
.map(username => ({username}))
.concat(pendingReviewers)
.value();
}

pendingReviewers = _.uniqBy(pendingReviewers, 'username');

const description =
(numRejections ? `${numRejections} change requests, ` : '') +
`${numApprovals} of ${numApprovalsRequired} approvals obtained`;
const shortDescription =
(numRejections ? `${numRejections} ✗, ` : '') + `${numApprovals} of ${numApprovalsRequired} ✓`;

return {
completed: numApprovals >= numApprovalsRequired,
description, shortDescription, pendingReviewers
};
4 changes: 4 additions & 0 deletions .reviewable/settings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Reviewable settings file. Read the docs at https://docs.reviewable.io/repositories.html#store-repository-settings-using-the-reviewable-directory
approval-text: ":lgtm_strong:"
github-status:
updates: always
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ RUN ["make", "toktok-site"]
COPY .md-style.rb /home/builder/build/
RUN ["make", "lint"]
RUN . /path/to/venv/bin/activate \
&& make check
&& make check \
&& mv toktok-site _site

WORKDIR /home/builder/build/toktok-site
WORKDIR /home/builder/build/_site
ENTRYPOINT ["/home/builder/entrypoint.sh"]
3 changes: 0 additions & 3 deletions netlify.toml

This file was deleted.

0 comments on commit 9eedd5f

Please sign in to comment.