Create deployments on push events in GitHub repo (#69)

* Create repo webhook and express handler for webhook

* Create deployments from commits in GitHub

* Update isCurrent in previous production deployment

* Create script for setting authority

* Update README for initialize registry script

* Handle review changes

* Use correct repo URL in record data

* Handle github unique webhook error

* Handle async execution of publishing records

* Update readme with ngrok setup

* Review changes

* Add logs for GitHub webhooks

---------

Co-authored-by: neeraj <neeraj.rtly@gmail.com>
This commit is contained in:
2024-02-15 17:24:57 +05:30
committed by GitHub
co-authored by neeraj
parent 9921dc5186
commit c4ba59d97e
19 changed files with 289 additions and 102 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
REACT_APP_GQL_SERVER_URL = 'http://localhost:8000/graphql'
REACT_APP_GITHUB_CLIENT_ID =
REACT_APP_GITHUB_CLIENT_ID =
REACT_APP_GITHUB_TEMPLATE_REPO =
@@ -3,10 +3,10 @@ import React from 'react';
import { Typography, IconButton } from '@material-tailwind/react';
import { relativeTimeISO } from '../../../utils/time';
import { GitCommitDetails } from '../../../types';
import { GitCommitWithBranch } from '../../../types';
interface ActivityCardProps {
activity: GitCommitDetails;
activity: GitCommitWithBranch;
}
const ActivityCard = ({ activity }: ActivityCardProps) => {
@@ -33,13 +33,19 @@ const CreateRepo = () => {
assert(data.account);
try {
assert(
process.env.REACT_APP_GITHUB_TEMPLATE_REPO,
'Config REACT_APP_GITHUB_TEMPLATE_REPO is not set in .env',
);
const [owner, repo] =
process.env.REACT_APP_GITHUB_TEMPLATE_REPO.split('/');
// TODO: Handle this functionality in backend
const gitRepo = await octokit?.rest.repos.createUsingTemplate({
template_owner: 'github-rest',
template_repo: 'test-progressive-web-app',
template_owner: owner,
template_repo: repo,
owner: data.account,
name: data.repoName,
description: 'This is your first repository',
include_all_branches: false,
private: data.isPrivate,
});
@@ -60,6 +66,7 @@ const CreateRepo = () => {
`/${orgSlug}/projects/create/template/deploy?projectId=${addProject.id}`,
);
} catch (err) {
console.error(err);
toast.error('Error deploying project');
}
},
@@ -8,7 +8,7 @@ import { Typography, Button, Chip, Avatar } from '@material-tailwind/react';
import ActivityCard from '../../../../components/projects/project/ActivityCard';
import { relativeTimeMs } from '../../../../utils/time';
import { useOctokit } from '../../../../context/OctokitContext';
import { GitCommitDetails, OutletContextType } from '../../../../types';
import { GitCommitWithBranch, OutletContextType } from '../../../../types';
import { useGQLClient } from '../../../../context/GQLClientContext';
const COMMITS_PER_PAGE = 4;
@@ -16,7 +16,7 @@ const COMMITS_PER_PAGE = 4;
const OverviewTabPanel = () => {
const { octokit } = useOctokit();
const navigate = useNavigate();
const [activities, setActivities] = useState<GitCommitDetails[]>([]);
const [activities, setActivities] = useState<GitCommitWithBranch[]>([]);
const [liveDomain, setLiveDomain] = useState<Domain>();
const client = useGQLClient();
@@ -78,6 +78,7 @@ const OverviewTabPanel = () => {
throw err;
}
// TODO: Show warning in activity section on request error
console.log(err.message);
}
};
+1 -1
View File
@@ -29,7 +29,7 @@ export interface GitBranchDetails {
name: string;
}
export interface GitCommitDetails {
export interface GitCommitWithBranch {
branch: GitBranchDetails;
commit: {
author: {